diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-08-16 10:57:32 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-08-16 10:57:32 +0200 |
commit | c4b6357a9908fb05261efa8764e5c8a6d8727b96 (patch) | |
tree | f08c518af05721cbee7f3738e66d97b905f02e87 /odb/validator.cxx | |
parent | 09d7377f81aeb8fde4aa1698e946457f03380d45 (diff) |
Implement soft delete for persistent classes
Diffstat (limited to 'odb/validator.cxx')
-rw-r--r-- | odb/validator.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
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<location_t> ("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")) |