From 3e57c662b42831555498607d607c349f30c5b7de 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/relational/sqlite/schema.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'odb') diff --git a/odb/relational/sqlite/schema.cxx b/odb/relational/sqlite/schema.cxx index 253772d..77a9590 100644 --- a/odb/relational/sqlite/schema.cxx +++ b/odb/relational/sqlite/schema.cxx @@ -19,6 +19,7 @@ namespace relational // // Create. // + struct object_columns: relational::object_columns, context { object_columns (base const& x): base (x) {} @@ -61,6 +62,21 @@ namespace relational } } + virtual void + reference (semantics::data_member& m) + { + // In SQLite, by default, constraints are immediate. + // + if (semantics::class_* c = object_pointer (member_type (m, prefix_))) + { + os << " REFERENCES " << table_qname (*c) << " (" << + column_qname (*id_member (*c)) << ") " << + "DEFERRABLE INITIALLY DEFERRED"; + } + else + base::reference (m); + } + }; entry object_columns_; } -- cgit v1.1