From 73c98a67ef4ed605cf69e0d212934c4dc1f3eb8e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 19 Jul 2011 13:42:18 +0200 Subject: 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). --- odb/context.hxx | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'odb/context.hxx') diff --git a/odb/context.hxx b/odb/context.hxx index 54f6832..a256866 100644 --- a/odb/context.hxx +++ b/odb/context.hxx @@ -123,6 +123,12 @@ public: return c.abstract () || c.count ("abstract"); } + bool + null (semantics::data_member&); + + bool + null (semantics::data_member&, string const& key_prefix); + // Database names and types. // public: @@ -225,23 +231,6 @@ public: return pointer_kind (p) == pk_weak; } - bool - null_pointer (semantics::data_member& m) - { - return !(m.count ("not-null") || m.type ().count ("not-null")); - } - - bool - null_pointer (semantics::data_member& m, string const& key_prefix) - { - if (key_prefix.empty ()) - return null_pointer (m); - - return !(m.count (key_prefix + "-not-null") || - m.type ().count ("not-null") || - member_type (m, key_prefix).count ("not-null")); - } - semantics::data_member* inverse (semantics::data_member& m) { @@ -441,33 +430,19 @@ public: // Per-database customizable functionality. // protected: - typedef unsigned short column_type_flags; - - static column_type_flags const ctf_none = 0; - - // Default type should be NULL-able. - // - static column_type_flags const ctf_default_null = 0x01; - // Return empty string if there is no mapping. // string - database_type (semantics::type& t, - semantics::names* hint, - semantics::context& c, - column_type_flags f) + database_type (semantics::type& t, semantics::names* hint, bool id) { - return current ().database_type_impl (t, hint, c, f); + return current ().database_type_impl (t, hint, id); } // The default implementation uses the type map (populated by the database- // specific context implementation) to come up with a mapping. // virtual string - database_type_impl (semantics::type&, - semantics::names*, - semantics::context&, - column_type_flags); + database_type_impl (semantics::type&, semantics::names*, bool); public: typedef context root_context; -- cgit v1.1