aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/connection.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-22 10:47:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-22 10:47:30 +0200
commit5a69eecefb4f5d29d7ab76f81e69ab27d85586cf (patch)
treec9b91104b4ec595ce836c95c561cf155fa647bea /odb/sqlite/connection.cxx
parent5694c0a4529334756f2b914ad67408df199551dc (diff)
Enable foreign key constraints checking in SQLite
Due to bugs in SQLite DDL foreign key support, we have to temporarily disable foreign keys when re-creating the schema. New manual section: 12.5.3, "Foreign Key Constraints".
Diffstat (limited to 'odb/sqlite/connection.cxx')
-rw-r--r--odb/sqlite/connection.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx
index d90c301..ffb70a7 100644
--- a/odb/sqlite/connection.cxx
+++ b/odb/sqlite/connection.cxx
@@ -66,6 +66,16 @@ namespace odb
translate_error (e, *this);
}
+ // Enable/disable foreign key constraints.
+ //
+ simple_statement st (
+ *this,
+ db.foreign_keys ()
+ ? "PRAGMA foreign_keys=ON"
+ : "PRAGMA foreign_keys=OFF",
+ db.foreign_keys () ? 22 : 23);
+ st.execute ();
+
statement_cache_.reset (new statement_cache_type (*this));
}