summaryrefslogtreecommitdiff
path: root/odb/relational/schema.hxx
diff options
context:
space:
mode:
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";
}
}