summaryrefslogtreecommitdiff
path: root/odb/relational/mysql/schema.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-07-19 13:42:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-07-19 13:42:18 +0200
commit73c98a67ef4ed605cf69e0d212934c4dc1f3eb8e (patch)
tree8645cd8d06f218ff5d945b1b3b94a58a127753c4 /odb/relational/mysql/schema.cxx
parent12d0d9bbd0f5b7295c50fd5b223e538afe1abbf7 (diff)
New design for NULL semantics
Now, instead of being specified as part of the SQL type with the type pragma, there are separate null and not_null pragmas. The not_null pragma was used to control NULL-ness of object pointers. Now the two pragmas are used consistently for object pointers and simple values (and in the future will work for composite values and containers).
Diffstat (limited to 'odb/relational/mysql/schema.cxx')
-rw-r--r--odb/relational/mysql/schema.cxx18
1 files changed, 17 insertions, 1 deletions
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);