diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | odb/relational/mysql/schema.cxx | 23 | ||||
-rw-r--r-- | odb/relational/schema.hxx | 6 |
3 files changed, 7 insertions, 25 deletions
@@ -11,6 +11,9 @@ Version 2.3.0 * The --output-name option has been renamed to --input-name, which is more semantically correct. + * The generated database schemas now explicitly specify NULL for nullable + columns. + Version 2.2.0 * Multi-database support. This mechanism allows an application to diff --git a/odb/relational/mysql/schema.cxx b/odb/relational/mysql/schema.cxx index 6ce619b..2ae47ae 100644 --- a/odb/relational/mysql/schema.cxx +++ b/odb/relational/mysql/schema.cxx @@ -143,29 +143,6 @@ namespace relational create_column (base const& x): base (x) {} virtual void - null (sema_rel::column& c) - { - // 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 (c.null ()) - { - // This should never fail since we have already parsed this. - // - sql_type const& t (parse_sql_type (c.type ())); - - if (t.type == sql_type::TIMESTAMP) - { - os << " NULL"; - return; - } - } - - base::null (c); - } - - virtual void auto_ (sema_rel::column&) { os << " AUTO_INCREMENT"; diff --git a/odb/relational/schema.hxx b/odb/relational/schema.hxx index 69e8089..fcb176f 100644 --- a/odb/relational/schema.hxx +++ b/odb/relational/schema.hxx @@ -410,8 +410,10 @@ namespace relational virtual void null (sema_rel::column& c) { - if (!c.null ()) - os << " NOT NULL"; + // Specify both cases explicitly for better readability, + // especially in ALTER COLUMN clauses. + // + os << (c.null () ? " NULL" : " NOT NULL"); } virtual void |