From c4b6357a9908fb05261efa8764e5c8a6d8727b96 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Aug 2013 10:57:32 +0200 Subject: Implement soft delete for persistent classes --- odb/validator.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'odb/validator.cxx') diff --git a/odb/validator.cxx b/odb/validator.cxx index 080aaa4..2b0b46e 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -326,6 +326,38 @@ namespace virtual void traverse_object (type& c) { + // Check the the deletion version makes sense. + // + if (unsigned long long v = deleted (c)) + { + location_t l (c.get ("deleted-location")); + + if (!versioned ()) + { + error (l) << "deleted member in non-versioned object model" << endl; + valid_ = false; + } + else + { + model_version const& mv (version ()); + + if (v > mv.current) + { + error (l) << "deletion version is greater than the current " << + "model version" << endl; + valid_ = false; + } + else if (v <= mv.base) + { + error (l) << "deletion version is less than or equal to the " << + "base model version" << endl; + info (c.location ()) << "delete this class since migration to " << + "version " << v << " is no longer possible" << endl; + valid_ = false; + } + } + } + // Check that the callback function exist. // if (c.count ("callback")) -- cgit v1.1