From c3c42b69ee9cda9634573497c4476a05c1f3d049 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Sep 2013 06:56:02 +0200 Subject: Make sure that soft-add/delete version is current version --- odb/relational/model.hxx | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'odb/relational/model.hxx') diff --git a/odb/relational/model.hxx b/odb/relational/model.hxx index e345f83..8920825 100644 --- a/odb/relational/model.hxx +++ b/odb/relational/model.hxx @@ -5,6 +5,7 @@ #ifndef ODB_RELATIONAL_MODEL_HXX #define ODB_RELATIONAL_MODEL_HXX +#include #include #include #include @@ -19,6 +20,8 @@ namespace relational namespace model { typedef std::set tables; + typedef std::map deleted_table_map; + typedef std::map deleted_column_map; struct object_columns: object_columns_base, virtual context { @@ -102,8 +105,11 @@ namespace relational virtual bool traverse_column (semantics::data_member& m, string const& name, bool) { - if (deleted (member_path_)) + if (semantics::data_member* m = deleted_member (member_path_)) + { + table_.get ("deleted-map")[name] = m; return false; + } string col_id (id_prefix_ + (key_prefix_.empty () ? m.name () : key_prefix_)); @@ -112,6 +118,7 @@ namespace relational model_.new_node ( col_id, column_type (), null (m))); c.set ("cxx-location", m.location ()); + c.set ("member-path", member_path_); model_.new_edge (table_, c, name); // An id member cannot have a default value. @@ -233,14 +240,20 @@ namespace relational using sema_rel::column; using sema_rel::foreign_key; - if (deleted (member_path_)) - return; - // Ignore inverse object pointers. // if (inverse (m, key_prefix_)) return; + if (deleted (member_path_)) + { + // Still traverse it as columns so that we can populate the + // deleted map. + // + object_columns_base::traverse_pointer (m, c); + return; + } + string id (id_prefix_ + (key_prefix_.empty () ? m.name () : key_prefix_)); @@ -494,18 +507,22 @@ namespace relational using sema_rel::column; - if (deleted (member_path_)) - return; - // Ignore inverse containers of object pointers. // if (inverse (m, "value")) return; container_kind_type ck (container_kind (ct)); - qname const& name (table_name (m, table_prefix_)); + // Ignore deleted container members. + // + if (semantics::data_member* m = deleted_member (member_path_)) + { + model_.get ("deleted-map")[name] = m; + return; + } + // Add the [] decorator to distinguish this id from non-container // ids (we don't want to ever end up comparing, for example, an // object table to a container table). @@ -514,6 +531,8 @@ namespace relational sema_rel::table& t (model_.new_node (id)); t.set ("cxx-location", m.location ()); + t.set ("member-path", member_path_); + t.set ("deleted-map", deleted_column_map ()); model_.new_edge (model_, t, name); t.options (table_options (m, ct)); @@ -718,21 +737,25 @@ namespace relational if (abstract (c) && !polymorphic (c)) return; - if (deleted (c)) - return; - qname const& name (table_name (c)); - // If the table with this name was already created, assume the + // If the table with this name was already seen, assume the // user knows what they are doing and skip it. // if (tables_.count (name)) return; + if (deleted (c)) + { + model_.get ("deleted-map")[name] = &c; + return; + } + string id (class_fq_name (c), 2); // Remove leading '::'. sema_rel::table& t (model_.new_node (id)); t.set ("cxx-location", c.location ()); + t.set ("deleted-map", deleted_column_map ()); model_.new_edge (model_, t, name); t.options (table_options (c)); -- cgit v1.1