mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 19:11:39 -06:00
Fix foreign key check after editing a table
After editing a table we perform a foreign key check to see if the modifications caused any problems. This check doesn't seem to work because it expected that in case of a problem the PRAGMA would fail. This however isn't the case - it just doesn't return any results but it doesn't fail. This commit fixes the check and only shows rolls back if the PRAGMA returned any data.
This commit is contained in:
@@ -996,7 +996,7 @@ void MainWindow::editObject()
|
||||
|
||||
// If foreign_keys were enabled, we must commit or rollback the transaction so the foreign_keys pragma can be restored.
|
||||
if (foreign_keys == "1") {
|
||||
if (!db.executeSQL(QString("PRAGMA %1.foreign_key_check").arg(sqlb::escapeIdentifier(name.schema())))) {
|
||||
if (!db.querySingeValueFromDb(QString("PRAGMA %1.foreign_key_check").arg(sqlb::escapeIdentifier(name.schema()))).isNull()) {
|
||||
QMessageBox::warning(this, QApplication::applicationName(),
|
||||
tr("Error checking foreign keys after table modification. The changes will be reverted.\n"
|
||||
"Message from database engine:\n%1").arg(db.lastError()));
|
||||
|
||||
Reference in New Issue
Block a user