From 51956f409ec7ebea8b6790b0c5d4f0b51513d683 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 15 Sep 2013 12:46:09 +0200 Subject: Cleanup polymorphic base tables when dropping derived one --- odb/semantics/relational/primary-key.hxx | 2 +- odb/semantics/relational/table.cxx | 17 ++++++++++++++++- odb/semantics/relational/table.hxx | 12 ++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) (limited to 'odb/semantics/relational') diff --git a/odb/semantics/relational/primary-key.hxx b/odb/semantics/relational/primary-key.hxx index 0f28966..e41ffc3 100644 --- a/odb/semantics/relational/primary-key.hxx +++ b/odb/semantics/relational/primary-key.hxx @@ -20,7 +20,7 @@ namespace semantics bool auto_ () const {return auto__;} - // Extra database information. + // Extra information. // public: typedef std::map extra_map; diff --git a/odb/semantics/relational/table.cxx b/odb/semantics/relational/table.cxx index 80add9f..8346d4c 100644 --- a/odb/semantics/relational/table.cxx +++ b/odb/semantics/relational/table.cxx @@ -16,7 +16,8 @@ namespace semantics table (table const& t, qscope& s, graph& g, bool b) : qnameable (t, g), uscope (t, (b ? s.lookup (t.name ()) : 0), g), - options_ (t.options_) + options_ (t.options_), + extra_map_ (t.extra_map_) { } @@ -30,6 +31,16 @@ namespace semantics g), options_ (p.attribute ("options", string ())) { + // All unhandled attributes go into the extra map. + // + typedef xml::parser::attribute_map_type attr_map; + attr_map const& am (p.attribute_map ()); + + for (attr_map::const_iterator i (am.begin ()); i != am.end (); ++i) + { + if (!i->second.handled) + extra_map_[i->first.name ()] = i->second.value; + } } table& table:: @@ -45,6 +56,10 @@ namespace semantics if (!options_.empty ()) s.attribute ("options", options_); + + for (extra_map::const_iterator i (extra_map_.begin ()); + i != extra_map_.end (); ++i) + s.attribute (i->first, i->second); } void table:: diff --git a/odb/semantics/relational/table.hxx b/odb/semantics/relational/table.hxx index f46eec1..99c65b7 100644 --- a/odb/semantics/relational/table.hxx +++ b/odb/semantics/relational/table.hxx @@ -20,6 +20,17 @@ namespace semantics virtual void options (string const& o) {options_ = o;} + // Extra information. + // + public: + typedef std::map extra_map; + + extra_map& + extra () {return extra_map_;} + + extra_map const& + extra () const {return extra_map_;} + public: table (string const& id): qnameable (id) {} table (table const&, qscope&, graph&, bool base = false); @@ -44,6 +55,7 @@ namespace semantics protected: string options_; + extra_map extra_map_; }; class add_table: public table -- cgit v1.1