Skip to content

Commit 212116a

Browse files
committed
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.
1 parent 0387999 commit 212116a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sqlitedb.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ bool DBBrowserDB::create ( const QString & db)
321321

322322
if (_db)
323323
{
324+
// set preference defaults
325+
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
326+
settings.sync();
327+
bool foreignkeys = settings.value( "/db/foreignkeys", false ).toBool();
328+
setPragma("foreign_keys", foreignkeys ? "1" : "0");
329+
324330
// Enable extension loading
325331
sqlite3_enable_load_extension(_db, 1);
326332

0 commit comments

Comments
 (0)