diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-22 10:47:30 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-22 10:47:30 +0200 |
commit | 5a69eecefb4f5d29d7ab76f81e69ab27d85586cf (patch) | |
tree | c9b91104b4ec595ce836c95c561cf155fa647bea /odb/sqlite/connection.cxx | |
parent | 5694c0a4529334756f2b914ad67408df199551dc (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.cxx | 10 |
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)); } |