diff options
-rw-r--r-- | odb/relational/mysql/source.cxx | 3 | ||||
-rw-r--r-- | odb/relational/source.cxx | 1 | ||||
-rw-r--r-- | odb/relational/sqlite/source.cxx | 16 |
3 files changed, 16 insertions, 4 deletions
diff --git a/odb/relational/mysql/source.cxx b/odb/relational/mysql/source.cxx index 65ff711..af37598 100644 --- a/odb/relational/mysql/source.cxx +++ b/odb/relational/mysql/source.cxx @@ -679,7 +679,8 @@ namespace relational virtual void init_auto_id (semantics::data_member&, string const& im) { - os << im << "value = 0;"; + os << im << "value = 0;" + << endl; } virtual string diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx index 8ead851..238eceb 100644 --- a/odb/relational/source.cxx +++ b/odb/relational/source.cxx @@ -1261,7 +1261,6 @@ traverse_object (type& c) string const& n (idf->name ()); string var ("im." + n + (n[n.size () - 1] == '_' ? "" : "_")); init_auto_id (*idf, var); // idf == idb, since auto - os << endl; } os << "if ("; diff --git a/odb/relational/sqlite/source.cxx b/odb/relational/sqlite/source.cxx index 2f6623e..072480d 100644 --- a/odb/relational/sqlite/source.cxx +++ b/odb/relational/sqlite/source.cxx @@ -412,9 +412,21 @@ namespace relational class_ (base const& x): base (x) {} virtual void - init_auto_id (semantics::data_member&, string const& im) + init_auto_id (semantics::data_member& m, string const& im) { - os << im << "null = true;"; + // Don't set the id value to NULL if this is a nullable wrapper. + // This will allow the user to control whether the value is auto or + // manually assigned by using something like this: + // + // #pragma db auto + // odb::nullable<int64_t> id; + // + semantics::type& t (utype (m)); + if (wrapper (t) && t.template get<bool> ("wrapper-null-handler")) + return; + + os << im << "null = true;" + << endl; } virtual string |