diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-15 14:02:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-15 14:02:14 +0200 |
commit | 6fa815e7f5a449e9805ba9e823ff41af5d2bdbbe (patch) | |
tree | 23783d9e24768859094b04ea58f9e929e60b271d | |
parent | c17f5ff5b2f1523e92e048623f51638f83b34022 (diff) |
Improve diagnostics for hard-deleted containers and objects
-rw-r--r-- | odb/relational/changelog.cxx | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/odb/relational/changelog.cxx b/odb/relational/changelog.cxx index a66a9e3..ca796a9 100644 --- a/odb/relational/changelog.cxx +++ b/odb/relational/changelog.cxx @@ -672,19 +672,37 @@ namespace relational // At first, it may seem like a good idea not to warn about // class deletions since it is not possible to do anything // useful with a class without referencing it from the code - // (in C++ sense). However, things get tricky one we consider + // (in C++ sense). However, things get tricky once we consider // polymorphism since the migration code could be "working" // with the hard-deleted derived class via its base. So we - // going to warn about everything and let the user decide. + // are going to warn about polymorphic derived tables. // else if (ops.warn_hard_delete () && version->open) { - // There is no way to distinguish between object and - // container tables. We also don't have any sensible - // location. + string k (t.extra ()["kind"]); + + // We don't have any sensible location. // - cerr << in_name << ": warning: object or container " << - "table '" << t.name () << "' is hard-deleted" << endl; + if (k == "container") + { + // We will issue a useless warning if the object table + // that this container references is also deleted. + // While we could detect this, it is going to require + // some effort since we would have to delay the warning + // and check later once we know all the deleted tables. + // + cerr << in_name << ": warning: container table '" << + t.name () << "' is hard-deleted" << endl; + } + else if (k == "polymorphic derived object") + { + // The same as above: the warning will be useless if + // we are dropping the whole hierarchy. + // + cerr << in_name << ": warning: polymorphic derived " << + "object table '" << t.name () << "' is hard-deleted" << + endl; + } } } |