From 212116ae182c657ec09219f3d3d7d2ce6fb518ec Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 21 Jun 2015 22:23:54 +0200 Subject: [PATCH] Also set foreign key preferences when creating a new database When opening a database we set the foreign key constraint checking according to the preferences set in the Preferences Dialog. But when creating a new database this wasn't done accordingly which means the behaviour of the application is different depending on wether a database was opened or newly created. This is changed by this commit. --- src/sqlitedb.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index c7d0cbb0..1d583067 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -321,6 +321,12 @@ bool DBBrowserDB::create ( const QString & db) if (_db) { + // set preference defaults + QSettings settings(QApplication::organizationName(), QApplication::organizationName()); + settings.sync(); + bool foreignkeys = settings.value( "/db/foreignkeys", false ).toBool(); + setPragma("foreign_keys", foreignkeys ? "1" : "0"); + // Enable extension loading sqlite3_enable_load_extension(_db, 1);