From 5a69eecefb4f5d29d7ab76f81e69ab27d85586cf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2011 10:47:30 +0200 Subject: 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". --- odb/sqlite/connection.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'odb/sqlite/connection.cxx') 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)); } -- cgit v1.1