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/column.hxx | |
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/column.hxx')
-rw-r--r-- | odb/semantics/relational/column.hxx | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/odb/semantics/relational/column.hxx b/odb/semantics/relational/column.hxx index 7702a13..11a76e0 100644 --- a/odb/semantics/relational/column.hxx +++ b/odb/semantics/relational/column.hxx @@ -19,35 +19,32 @@ namespace semantics typedef std::vector<contains*> contained_list; public: - string const& + virtual string const& type () const {return type_;} - bool + virtual bool null () const {return null_;} - void + virtual void null (bool n) {null_ = n;} - string const& + virtual string const& default_ () const {return default__;} - void + virtual void default_ (string const& d) {default__ = d;} - string const& + virtual string const& options () const {return options_;} - void + virtual void options (string const& o) {options_ = o;} public: typedef relational::table table_type; table_type& - table () const - { - return dynamic_cast<table_type&> (scope ()); - } + table () const {return dynamic_cast<table_type&> (scope ());} // Key containment. // @@ -95,12 +92,13 @@ namespace semantics void serialize_attributes (xml::serializer&) const; - private: + protected: string type_; bool null_; string default__; string options_; + private: contained_list contained_; }; @@ -140,24 +138,34 @@ namespace semantics serialize (xml::serializer&) const; }; - class alter_column: public unameable + class alter_column: public column { public: + virtual string const& + type () const {return base ().type ();} + bool null_altered () const {return null_altered_;} - bool - null () const {return null_;} + virtual bool + null () const {return null_altered_ ? null_ : base ().null ();} - void + virtual void null (bool n) {null_ = n; null_altered_ = true;} + virtual string const& + default_ () const {return base ().default_ ();} + + virtual string const& + options () const {return base ().options ();} + public: - alter_column (string const& id) - : unameable (id), null_altered_ (false) - { - } + column& + base () const {return dynamic_cast<column&> (alters_->base ());} + public: + alter_column (string const& id) + : column (id, "", false), alters_ (0), null_altered_ (false) {} alter_column (alter_column const&, uscope&, graph&); alter_column (xml::parser&, uscope&, graph&); @@ -173,9 +181,17 @@ namespace semantics virtual void serialize (xml::serializer&) const; + virtual void + add_edge_left (alters& a) + { + assert (alters_ == 0); + alters_ = &a; + } + private: + alters* alters_; + bool null_altered_; - bool null_; }; } } |