diff options
Diffstat (limited to 'odb/relational/mysql')
-rw-r--r-- | odb/relational/mysql/context.cxx | 10 | ||||
-rw-r--r-- | odb/relational/mysql/context.hxx | 5 | ||||
-rw-r--r-- | odb/relational/mysql/schema.cxx | 18 | ||||
-rw-r--r-- | odb/relational/mysql/source.cxx | 4 |
4 files changed, 22 insertions, 15 deletions
diff --git a/odb/relational/mysql/context.cxx b/odb/relational/mysql/context.cxx index e9446c2..431470a 100644 --- a/odb/relational/mysql/context.cxx +++ b/odb/relational/mysql/context.cxx @@ -234,12 +234,9 @@ namespace relational } string context:: - database_type_impl (semantics::type& t, - semantics::names* hint, - semantics::context& ctx, - column_type_flags f) + database_type_impl (semantics::type& t, semantics::names* hint, bool id) { - string r (base_context::database_type_impl (t, hint, ctx, f)); + string r (base_context::database_type_impl (t, hint, id)); if (!r.empty ()) return r; @@ -290,9 +287,6 @@ namespace relational if (e->unsigned_ ()) r += " UNSIGNED"; } - - if ((f & ctf_default_null) == 0) - r += " NOT NULL"; } return r; diff --git a/odb/relational/mysql/context.hxx b/odb/relational/mysql/context.hxx index 019b878..00ebe57 100644 --- a/odb/relational/mysql/context.hxx +++ b/odb/relational/mysql/context.hxx @@ -97,10 +97,7 @@ namespace relational protected: virtual string - database_type_impl (semantics::type&, - semantics::names*, - semantics::context&, - column_type_flags); + database_type_impl (semantics::type&, semantics::names*, bool); public: virtual diff --git a/odb/relational/mysql/schema.cxx b/odb/relational/mysql/schema.cxx index 0b44c53..3848c75 100644 --- a/odb/relational/mysql/schema.cxx +++ b/odb/relational/mysql/schema.cxx @@ -37,11 +37,27 @@ namespace relational } }; - struct object_columns: relational::object_columns + struct object_columns: relational::object_columns, context { object_columns (base const& x): base (x) {} virtual void + null (semantics::data_member& m) + { + if (!context::null (m, prefix_)) + os << " NOT NULL"; + else + { + // MySQL TIMESTAMP is by default NOT NULL. If we want it + // to contain NULL values, we need to explicitly declare + // the column as NULL. + // + if (column_sql_type (m, prefix_).type == sql_type::TIMESTAMP) + os << " NULL"; + } + } + + virtual void constraints (semantics::data_member& m) { base::constraints (m); diff --git a/odb/relational/mysql/source.cxx b/odb/relational/mysql/source.cxx index 17bffdc..d3b4129 100644 --- a/odb/relational/mysql/source.cxx +++ b/odb/relational/mysql/source.cxx @@ -588,7 +588,7 @@ namespace relational { os << "}"; - if (!null_pointer (mi.m, key_prefix_)) + if (!null (mi.m, key_prefix_)) os << "else" << endl << "throw null_pointer ();"; } @@ -786,7 +786,7 @@ namespace relational << endl << "if (i." << mi.var << "null)" << endl; - if (null_pointer (mi.m, key_prefix_)) + if (null (mi.m, key_prefix_)) os << member << " = ptr_traits::pointer_type ();"; else os << "throw null_pointer ();"; |