From 6ed5736f519caf6f3637051a2e142e8ce6575707 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Aug 2011 11:08:12 +0200 Subject: Make container object_id reference the object Make it ON DELETE CASCADE. Also in erase(), delete the container rows first. --- odb/relational/schema.hxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'odb/relational/schema.hxx') 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"; } } -- cgit v1.1