summaryrefslogtreecommitdiff
path: root/odb/relational/schema.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-19 11:08:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-19 11:08:12 +0200
commit6ed5736f519caf6f3637051a2e142e8ce6575707 (patch)
treed6ba6e102b2388337ae69b6f3055dc1da5b78840 /odb/relational/schema.hxx
parent280c36de4544fc17dc3d4f1ea168e7d2dc859129 (diff)
Make container object_id reference the object
Make it ON DELETE CASCADE. Also in erase(), delete the container rows first.
Diffstat (limited to 'odb/relational/schema.hxx')
-rw-r--r--odb/relational/schema.hxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/odb/relational/schema.hxx b/odb/relational/schema.hxx
index 6ada960..9dbe067 100644
--- a/odb/relational/schema.hxx
+++ b/odb/relational/schema.hxx
@@ -277,8 +277,19 @@ namespace relational
{
if (semantics::class_* c = object_pointer (member_type (m, prefix_)))
{
- os << " REFERENCES " << quote_id (table_name (*c)) << " (" <<
- quote_id (column_name (*id_member (*c))) << ")";
+ os << " REFERENCES " << table_qname (*c) << " (" <<
+ column_qname (*id_member (*c)) << ")";
+ }
+ else if (prefix_ == "id")
+ {
+ // Container id column references the object table. It also
+ // cascades on delete so that we can delete the object with
+ // a single delete statement (needed for query_erase()).
+ //
+ semantics::class_& c (*context::top_object);
+
+ os << " REFERENCES " << table_qname (c) << " (" <<
+ column_qname (*id_member (c)) << ") ON DELETE CASCADE";
}
}