From 049d4ba76f6e12f6e7ca2a4922213707b7cff91f Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Tue, 28 Aug 2018 21:17:14 +0200 Subject: [PATCH] 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. --- src/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a6b2caae..3b0ed304 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -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()));