diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-03-28 16:04:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-10 18:46:44 +0200 |
commit | 2aa3cabf1b737e225178230882ee9aadfd817ce0 (patch) | |
tree | 85a6c7a90f8483ca11a4bc825cd2ef22114c3d97 /odb/semantics/relational/elements.cxx | |
parent | e999b1e7295acd8cdb646c2db7db1f5059f10c7d (diff) |
Add changelog support for add/drop index/foreign key
Also diagnose changes to primary keys and establish the 'alters'
association.
Diffstat (limited to 'odb/semantics/relational/elements.cxx')
-rw-r--r-- | odb/semantics/relational/elements.cxx | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/odb/semantics/relational/elements.cxx b/odb/semantics/relational/elements.cxx index e14bc00..d83bff7 100644 --- a/odb/semantics/relational/elements.cxx +++ b/odb/semantics/relational/elements.cxx @@ -45,23 +45,36 @@ namespace semantics { typename names_list::iterator i; - // We want the order to be columns first, then the primary key, - // and then the foreign keys. + // We want the order to be add/alter columns first, then the + // primary key, then other keys, and finnally drop columns. // - if (n.is_a<column> ()) + if (n.is_a<column> () || + n.is_a<add_column> () || + n.is_a<alter_column> ()) + { i = names_.insert (first_key_, &e); - else + } + else if (!n.is_a<drop_column> ()) { if (n.is_a<primary_key> ()) - first_key_ = i = names_.insert (first_key_, &e); + first_key_ = i = names_.insert ( + first_key_ != names_.end () ? first_key_ : first_drop_column_, + &e); else { - i = names_.insert (names_.end (), &e); + i = names_.insert (first_drop_column_, &e); if (first_key_ == names_.end ()) first_key_ = i; } } + else + { + i = names_.insert (names_.end (), &e); + + if (first_drop_column_ == names_.end ()) + first_drop_column_ = i; + } names_map_[name] = i; iterator_map_[&e] = i; @@ -83,6 +96,11 @@ namespace semantics if (first_key_ == i->second) first_key_++; + // The same for the first drop column. + // + if (first_drop_column_ == i->second) + first_drop_column_++; + names_.erase (i->second); names_map_.erase (e.name ()); iterator_map_.erase (i); @@ -106,6 +124,14 @@ namespace semantics // insert (type_info (typeid (edge))); + // alters + // + { + type_info ti (typeid (alters)); + ti.add_base (typeid (edge)); + insert (ti); + } + // names // { |