From f8b3ee6d42f5112c4e66a07cc7fdba43ce66aacd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Apr 2012 13:32:45 +0200 Subject: Support for NULL value semantics for composite values --- doc/manual.xhtml | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'doc') diff --git a/doc/manual.xhtml b/doc/manual.xhtml index dd7c649..c32cc37 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -6326,7 +6326,7 @@ CREATE TABLE person_nickname ( "null/not_null").

To properly support the NULL semantics, the - C++ value type must have a notion or a NULL + C++ value type must have a notion of a NULL value or a similar special state concept. Most basic C++ types, such as int or std::string, do not have this notion and therefore cannot be used directly @@ -6481,18 +6481,17 @@ class person Qt), provide support for smart pointers found in these frameworks and libraries (Part III, "Profiles").

-

Currently, ODB supports the NULL semantics only - for simple values. In future versions this support will be extended - to composite values and containers. With this limitation in mind, - we can still use smart pointers in data members of composite value - and container types. The only restriction is that these pointers - must not be NULL. For example:

+

ODB also supports the NULL semantics for composite + values. In the relational database the NULL composite + value is translated to NULL values for all the simple + data members of this composite value. For example:

 #pragma db value
 struct name
 {
   std::string first_;
+  odb::nullable<std::string> middle_;
   std::string last_;
 };
 
@@ -6500,9 +6499,24 @@ struct name
 class person
 {
   ...
+  odb::nullable<name> name_;
+};
+  
+ +

ODB does not support the NULL semantics for containers. + This also means that a composite value that contains a container + cannot be NULL. With this limitation in mind, we can + still use smart pointers in data members of container types. The + only restriction is that these pointers must not be NULL. + For example:

+ +
+#pragma db object
+class person
+{
+  ...
 
-  std::auto_ptr<name> name_;
-  std::auto_ptr<std::vector<name> > aliases_;
+  std::auto_ptr<std::vector<std::string> > aliases_;
 };
   
-- cgit v1.1