From 8d82c02a90cd7cc3f161828624db5b973585c34c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 27 Oct 2011 15:16:49 +0200 Subject: Add support for persistent classes without object ids New pragma id (object). New test: common/no-id. --- odb/relational/processor.cxx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'odb/relational/processor.cxx') diff --git a/odb/relational/processor.cxx b/odb/relational/processor.cxx index fdddf9a..d0587ca 100644 --- a/odb/relational/processor.cxx +++ b/odb/relational/processor.cxx @@ -851,6 +851,20 @@ namespace relational throw operation_failed (); } + // Make sure the pointed-to class has object id. + // + if (context::id_member (*c) == 0) + { + os << m.file () << ":" << m.line () << ":" << m.column () << ": " + << "error: pointed-to class '" << c->fq_name () << "' " + << "has no object id" << endl; + + os << c->file () << ":" << c->line () << ":" << c->column () << ": " + << "info: class '" << c->name () << "' is defined here" << endl; + + throw operation_failed (); + } + // See if this is the inverse side of a bidirectional relationship. // If so, then resolve the member and cache it in the context. // @@ -882,8 +896,9 @@ namespace relational } // @@ Would be good to check that the other end is actually - // an object pointer and is not marked as inverse. But the - // other class may not have been processed yet. + // an object pointer, is not marked as inverse, and points + // to the correct object. But the other class may not have + // been processed yet. // m.remove ("inverse"); m.set (kp + (kp.empty () ? "": "-") + "inverse", im); -- cgit v1.1