From 4b369b8791efa967911b5e526b210ad570d7ae05 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Jul 2011 13:38:06 +0200 Subject: Update manual with new null/not_null pragmas documentation --- doc/manual.xhtml | 619 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 411 insertions(+), 208 deletions(-) diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 395630f..c691f12 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -423,15 +423,16 @@ for consistency. - + - - - - + + + + +
10.2.1type
10.2.2id_type
10.2.3not_null
10.2.3null/not_null
10.2.4unordered
10.2.5index_type
10.2.6key_type
10.2.7value_type
10.2.8id_column
10.2.9index_column
10.2.10key_column
10.2.11value_column
10.2.8value_null/value_not_null
10.2.9id_column
10.2.10index_column
10.2.11key_column
10.2.12value_column
@@ -443,17 +444,18 @@ for consistency. 10.3.3type 10.3.4column 10.3.5transient - 10.3.6not_null + 10.3.6null/not_null 10.3.7inverse 10.3.8unordered 10.3.9table 10.3.10index_type 10.3.11key_type 10.3.12value_type - 10.3.13id_column - 10.3.14index_column - 10.3.15key_column - 10.3.16value_column + 10.3.13value_null/value_not_null + 10.3.14id_column + 10.3.15index_column + 10.3.16key_column + 10.3.17value_column @@ -2860,7 +2862,8 @@ namespace odb

The null_pointer exception is thrown when a pointer to a persistent object declared non-NULL - with the db not_null pragma has the NULL + with the db not_null or + db value_not_null pragma has the NULL value. See Chapter 6, "Relationships" for details.

The next three exceptions (already_in_transaction, @@ -3613,12 +3616,12 @@ class person { ... private: - #pragma db table("nicknames") \ - id_column ("person_id") \ - index_type ("SMALLINT UNSIGNED NOT NULL") \ - index_column ("nickname_number") \ - value_type ("VARCHAR(255) NOT NULL") \ - value_column ("nickname") + #pragma db table("nicknames") \ + id_column("person_id") \ + index_type("SMALLINT UNSIGNED") \ + index_column("nickname_number") \ + value_type("VARCHAR(255)") \ + value_column("nickname") std::vector<std::string> nicknames_; ... }; @@ -3701,10 +3704,10 @@ class person { ... private: - #pragma db table("emails") \ - id_column ("person_id") \ - value_type ("VARCHAR(255) NOT NULL") \ - value_column ("email") + #pragma db table("emails") \ + id_column("person_id") \ + value_type("VARCHAR(255)") \ + value_column("email") std::set<std::string> emails_; ... }; @@ -3763,12 +3766,12 @@ class person { ... private: - #pragma db table("weight_map") \ - id_column ("person_id") \ - key_type ("INT UNSIGNED NOT NULL") \ - key_column ("age") \ - value_type ("DOUBLE NOT NULL") \ - value_column ("weight") + #pragma db table("weight_map") \ + id_column("person_id") \ + key_type("INT UNSIGNED") \ + key_column("age") \ + value_type("DOUBLE") \ + value_column("weight") std::map<unsigned short, float> age_weight_map_; ... }; @@ -3879,8 +3882,13 @@ class employee

By default, an object pointer can be NULL. To - specify that a pointer always point to a valid object we can - use the not_null pragma, for example:

+ specify that a pointer always points to a valid object we can + use the not_null pragma (Section + 10.3.6, "null/not_null") for + single object pointers and the value_not_null pragma + (Section + 10.3.13, "value_null/value_not_null") + for containers of object pointers. For example:

 #pragma db object
@@ -3889,14 +3897,18 @@ class employee
   ...
 
   #pragma db not_null
-  shared_ptr<employer> employer_;
+  shared_ptr<employer> current_employer_;
+
+  #pragma db value_not_null
+  std::vector<shared_ptr<employer> > previous_employers_;
 };
   

In this case, if we perform a database operation on the - employee object and the employer_ - pointer is NULL, then the odb::null_pointer - exception will be thrown.

+ employee object and the current_employer_ + pointer or one of the pointers stored in the + previous_employers_ container is NULL, + then the odb::null_pointer exception will be thrown.

We don't need to do anything special to establish or navigate a relationship between two persistent objects, as shown in the @@ -4088,7 +4100,7 @@ class employee #pragma db id unsigned long id_; - #pragma db not_null unordered + #pragma db value_not_null unordered std::vector<shared_ptr<project> > projects_; }; @@ -4117,7 +4129,7 @@ class employee { ... - #pragma db not_null unordered \ + #pragma db value_not_null unordered \ id_column("employee_id") value_column("project_name") std::vector<shared_ptr<project> > projects_; }; @@ -4365,7 +4377,7 @@ class employer #pragma db id std::string name_; - #pragma db not_null inverse(employer_) + #pragma db value_not_null inverse(employer_) std::vector<weak_ptr<employee> > employees_ }; @@ -4430,7 +4442,7 @@ class project #pragma db id std::string name_; - #pragma db not_null inverse(projects_) + #pragma db value_not_null inverse(projects_) std::vector<weak_ptr<employee> > employees_; }; @@ -4442,7 +4454,7 @@ class employee #pragma db id unsigned long id_; - #pragma db not_null unordered + #pragma db value_not_null unordered std::vector<shared_ptr<project> > projects_; }; @@ -4492,7 +4504,7 @@ class employer #pragma db id std::string name_; - #pragma db not_null inverse(employer_) + #pragma db value_not_null inverse(employer_) std::vector<weak_ptr<employee> > employees_; }; @@ -4573,7 +4585,7 @@ class employer { ... - #pragma db not_null inverse(employer_) + #pragma db value_not_null inverse(employer_) std::vector<lazy_weak_ptr<employee> > employees_; }; @@ -5060,9 +5072,9 @@ CREATE TABLE person (

The same principle applies when a composite value type is used as an element of a container, except that instead of db column, either the db value_column - (Section 10.3.16, "value_column") or + (Section 10.3.17, "value_column") or db key_column - (Section 10.3.15, "key_column") + (Section 10.3.16, "key_column") pragmas are used to specify the column prefix.

When a composite value type contains a container, an extra table @@ -5094,10 +5106,10 @@ class person

The corresponding database schema will look like this:

-CREATE TABLE `person_name_nicknames` (
-  `object_id` BIGINT UNSIGNED NOT NULL,
-  `index` BIGINT UNSIGNED NOT NULL,
-  `value` TEXT NOT NULL)
+CREATE TABLE person_name_nicknames (
+  object_id BIGINT UNSIGNED NOT NULL,
+  index BIGINT UNSIGNED NOT NULL,
+  value TEXT NOT NULL)
 
 CREATE TABLE person (
   id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
@@ -5132,10 +5144,10 @@ class person
   

This will result in the following schema changes:

-CREATE TABLE `person_nickname` (
-  `object_id` BIGINT UNSIGNED NOT NULL,
-  `index` BIGINT UNSIGNED NOT NULL,
-  `value` TEXT NOT NULL)
+CREATE TABLE person_nickname (
+  object_id BIGINT UNSIGNED NOT NULL,
+  index BIGINT UNSIGNED NOT NULL,
+  value TEXT NOT NULL)
   

Similar to columns, we can make the table prefix empty.

@@ -5361,7 +5373,7 @@ CREATE TABLE permanent_employee ( CREATE TABLE temporary_employee ( first TEXT NOT NULL, - last` TEXT NOT NULL, + last TEXT NOT NULL, id BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, duration BIGINT UNSIGNED NOT NULL); @@ -5688,7 +5700,7 @@ namespace db named value type pragma to map a C++ type to a native database type:

-#pragma db value(bool) type("INT NOT NULL")
+#pragma db value(bool) type("INT")
 
 #pragma db object
 class person
@@ -6024,8 +6036,8 @@ private:
     
 
     
-      not_null
-      object pointer cannot be NULL
+      null/not_null
+      type can/cannot be NULL
       10.2.3
     
 
@@ -6054,27 +6066,33 @@ private:
     
 
     
+      value_null/value_not_null
+      container's value can/cannot be NULL
+      10.2.8
+    
+
+    
       id_column
       column name for a container's table object id
-      10.2.8
+      10.2.9
     
 
     
       index_column
       column name for a container's table index
-      10.2.9
+      10.2.10
     
 
     
       key_column
       column name for a container's table key
-      10.2.10
+      10.2.11
     
 
     
       value_column
       column name for a container's table value
-      10.2.11
+      10.2.12
     
 
   
@@ -6095,15 +6113,14 @@ private:
      that should be used for data members of this type. For example:

-#pragma db value(bool) type("INT NOT NULL")
+#pragma db value(bool) type("INT")
 
 #pragma db object
 class person
 {
   ...
-private:
+
   bool married_; // Mapped to INT NOT NULL database type.
-  ...
 };
   
@@ -6111,7 +6128,10 @@ private: types, such as bool, int, and std::string and the database types for each supported database system. For more information on the default mapping, - refer to Part II, "Database Systems".

+ refer to Part II, "Database Systems". The + null and not_null (Section + 10.2.3, "null/not_null") specifiers + can be used to control the NULL semantics of a type.

In the above example we changed the mapping for the bool type which is now mapped to the INT database type. In @@ -6124,7 +6144,7 @@ private: boolean value is stored in the database as a string:

-#pragma db value(bool) type("VARCHAR(5) NOT NULL")
+#pragma db value(bool) type("VARCHAR(5)")
   

The possible database values for the C++ true value could @@ -6149,14 +6169,13 @@ private: example:

-#pragma db value(std::string) type("TEXT NOT NULL") \
-                              id_type("VARCHAR(128) NOT NULL")
+#pragma db value(std::string) type("TEXT") id_type("VARCHAR(128)")
 
 #pragma db object
 class person
 {
   ...
-private:
+
   #pragma db id
   std::string email_; // Mapped to VARCHAR(128) NOT NULL.
 
@@ -6173,43 +6192,72 @@ private:
 class person
 {
   ...
-private:
-  #pragma db id type("VARCHAR(128) NOT NULL")
+
+  #pragma db id type("VARCHAR(128)")
   std::string email_;
-  ...
 };
   
-

10.2.3 not_null

+

10.2.3 null/not_null

-

The not_null specifier specifies that an object pointer - or a container of object pointers cannot have or contain the - NULL value. For example:

+

The null and not_null specifiers specify that + a value type or object pointer can or cannot be NULL, + respectively. By default, value types are assumed not to allow + NULL values while object pointers are assumed to + allow NULL values. Data members of types that allow + NULL values are mapped in a relational database to + columns that allow NULL values. For example:

 using std::tr1::shared_ptr;
 
+typedef shared_ptr<std::string> string_ptr;
+#pragma db value(string_ptr) type("TEXT") null
+
 #pragma db object
 class person
 {
   ...
+
+  string_ptr name_; // Mapped to TEXT NULL.
 };
 
 typedef shared_ptr<person> person_ptr;
 #pragma db value(person_ptr) not_null
+  
-#pragma db object -class account -{ - ... -}; +

The NULL semantics can also be specified on the + per-member basis (Section 10.3.6, + "null/not_null"). If both a type and + a member have null/not_null specifiers, + then the member specifier takes precedence. If a member specifier + relaxes the NULL semantics (that is, if a member has + the null specifier and the type has the explicit + not_null specifier), then a warning is issued.

-typedef std::vector<shared_ptr<account> > accounts; -#pragma db value(accounts) not_null -
+

It is also possible to override a previously specified + null/not_null specifier. This is + primarily useful if a third-party type, for example, + one provided by a profile library (Part III, + "Profiles"), allows NULL values but in your + object model data members of this type should never be + NULL. In this case you can use the not_null + specifier to disable NULL values for this type for the + entire translation unit. For example:

+ +
+// By default, null_string allows NULL values.
+//
+#include <null-string.hxx>
+
+// Disable NULL values for all the null_string data members.
+//
+#pragma db value(null_string) not_null
+  
-

For a more detailed discussion of the NULL object pointer - semantics, refer to Chapter 6, "Relationships".

+

For a more detailed discussion of the NULL semantics + for the object pointers, refer to Chapter 6, + "Relationships".

10.2.4 unordered

@@ -6239,7 +6287,7 @@ typedef std::vector<std::string> names;
 typedef std::vector<std::string> names;
-#pragma db value(names) index_type("SMALLINT UNSIGNED NOT NULL")
+#pragma db value(names) index_type("SMALLINT UNSIGNED")
   

10.2.6 key_type

@@ -6253,7 +6301,7 @@ typedef std::vector<std::string> names;
 typedef std::map<unsigned short, float> age_weight_map;
-#pragma db value(age_weight_map) key_type("INT UNSIGNED NOT NULL")
+#pragma db value(age_weight_map) key_type("INT UNSIGNED")
   

10.2.7 value_type

@@ -6267,10 +6315,42 @@ typedef std::map<unsigned short, float> age_weight_map;
 typedef std::vector<std::string> names;
-#pragma db value(names) value_type("VARCHAR(255) NOT NULL")
+#pragma db value(names) value_type("VARCHAR(255)")
   
-

10.2.8 id_column

+

The value_null and value_not_null + (Section 10.2.8, + "value_null/value_not_null") specifiers + can be used to control the NULL semantics of a value column.

+ +

10.2.8 value_null/value_not_null

+ +

The value_null and value_not_null specifiers + specify that a container type's element value can or cannot be + NULL, respectively. The semantics of value_null + and value_not_null are similar to that of the + null and not_null specifiers + (Section 10.2.3, "null/not_null"). + For example:

+ +
+using std::tr1::shared_ptr;
+
+#pragma db object
+class account
+{
+  ...
+};
+
+typedef std::vector<shared_ptr<account> > accounts;
+#pragma db value(accounts) value_not_null
+  
+ +

For set and multiset containers (Section 5.2, "Set and + Multiset Containers") the element value is automatically treated + as not alowing a NULL value.

+ +

10.2.9 id_column

The id_column specifier specifies the column name that should be used to store the object id in a @@ -6284,7 +6364,7 @@ typedef std::vector<std::string> names;

If the column name is not specified, then object_id is used by default.

-

10.2.9 index_column

+

10.2.10 index_column

The index_column specifier specifies the column name that should be used to store the element index in an @@ -6298,7 +6378,7 @@ typedef std::vector<std::string> names;

If the column name is not specified, then index is used by default.

-

10.2.10 key_column

+

10.2.11 key_column

The key_column specifier specifies the column name that should be used to store the key in a map @@ -6312,7 +6392,7 @@ typedef std::map<unsigned short, float> age_weight_map;

If the column name is not specified, then key is used by default.

-

10.2.11 value_column

+

10.2.12 value_column

The value_column specifier specifies the column name that should be used to store the element value in a @@ -6375,8 +6455,8 @@ typedef std::map<unsigned short, float> age_weight_map; - not_null - object pointer cannot be NULL + null/not_null + member can/cannot be NULL 10.3.6 @@ -6418,27 +6498,33 @@ typedef std::map<unsigned short, float> age_weight_map; + value_null/value_not_null + container's value can/cannot be NULL + 10.3.13 + + + id_column column name for a container's object id - 10.3.13 + 10.3.14 index_column column name for a container's index - 10.3.14 + 10.3.15 key_column column name for a container's key - 10.3.15 + 10.3.16 value_column column name for a container's value - 10.3.16 + 10.3.17 @@ -6464,10 +6550,9 @@ typedef std::map<unsigned short, float> age_weight_map; class person { ... -private: + #pragma db id std::string email_; - ... };

@@ -6485,10 +6570,9 @@ private: class person { ... -private: + #pragma db id auto unsigned long id_; - ... }; @@ -6512,13 +6596,16 @@ private: class person { ... -private: - #pragma db type("INT NOT NULL") + + #pragma db type("INT") bool married_; - ... }; +

The null and not_null (Section + 10.3.6, "null/not_null") specifiers + can be used to control the NULL semantics of a data member.

+

10.3.4 column

The column specifier specifies the column name @@ -6530,10 +6617,9 @@ private: class person { ... -private: + #pragma db id column("person_id") unsigned long id_; - ... }; @@ -6555,12 +6641,11 @@ private: class person { ... -private: + date born_; #pragma db transient unsigned short age_; // Computed from born_. - ... }; @@ -6568,11 +6653,23 @@ private: references that are only meaningful in the application's memory, as well as utility members such as mutexes, etc.

-

10.3.6 not_null

- -

The not_null specifier specifies that a data member of - an object pointer or a container of object pointers type cannot - have or contain the NULL value. For example:

+

10.3.6 null/not_null

+ +

The null and not_null specifiers specify that + a data member can or cannot be NULL, respectively. + By default, data members of basic value types for which database + mapping is provided by the ODB compiler do not allow NULL + values while data members of object pointers allow NULL + values. Other value types, such as those provided by the profile + libraries (Part III, "Profiles"), may or may + not allow NULL values, depending on the semantics + of each value type. Consult the relevant documentation to find + out more about the NULL semantics for such value + types. A data member containing the object id (Section + 10.3.1, "id" ) is automatically treated as not + allowing a NULL value. Data members that + allow NULL values are mapped in a relational database + to columns that allow NULL values. For example:

 using std::tr1::shared_ptr;
@@ -6581,24 +6678,33 @@ using std::tr1::shared_ptr;
 class person
 {
   ...
+
+  #pragma db null
+  std::string name_;
 };
 
 #pragma db object
 class account
 {
   ...
-private:
-  #pragma db not_null
-  shared_ptr<person> primary_holder_;
 
   #pragma db not_null
-  std::vector<shared_ptr<person> > secondary_holders_;
-  ...
+  shared_ptr<person> holder_;
 };
 
-

For a more detailed discussion of the NULL object pointer - semantics, refer to Chapter 6, "Relationships".

+

The NULL semantics can also be specified on the + per-type basis (Section 10.2.3, + "null/not_null"). If both a type and + a member have null/not_null specifiers, + then the member specifier takes precedence. If a member specifier + relaxes the NULL semantics (that is, if a member has + the null specifier and the type has the explicit + not_null specifier), then a warning is issued.

+ +

For a more detailed discussion of the NULL semantics + for the object pointers, refer to Chapter 6, + "Relationships".

10.3.7 inverse

@@ -6618,19 +6724,17 @@ class person; class employer { ... -private: + std::vector<shared_ptr<person> > employees_; - ... }; #pragma db object pointer(shared_ptr) class person { ... -private: + #pragma db inverse(employee_) weak_ptr<employer> employer_; - ... }; @@ -6658,10 +6762,9 @@ private: class person { ... -private: + #pragma db unordered std::vector<std::string> nicknames_; - ... }; @@ -6679,10 +6782,9 @@ private: class person { ... -private: + #pragma db table("nicknames") std::vector<std::string> nicknames_; - ... }; @@ -6714,10 +6816,9 @@ private: class person { ... -private: - #pragma db index_type("SMALLINT UNSIGNED NOT NULL") + + #pragma db index_type("SMALLINT UNSIGNED") std::vector<std::string> nicknames_; - ... }; @@ -6735,10 +6836,9 @@ private: class person { ... -private: - #pragma db key_type("INT UNSIGNED NOT NULL") + + #pragma db key_type("INT UNSIGNED") std::map<unsigned short, float> age_weight_map_; - ... }; @@ -6756,14 +6856,51 @@ private: class person { ... -private: - #pragma db value_type("VARCHAR(255) NOT NULL") + + #pragma db value_type("VARCHAR(255)") std::vector<std::string> nicknames_; +}; + + +

The value_null and value_not_null + (Section 10.3.13, + "value_null/value_not_null") specifiers + can be used to control the NULL semantics of a value column.

+ +

10.3.13 value_null/value_not_null

+ +

The value_null and value_not_null specifiers + specify that a container's element value for a data member can or + cannot be NULL, respectively. The semantics of + value_null and value_not_null are similar + to that of the null and not_null specifiers + (Section 10.3.6, "null/not_null"). + For example:

+ +
+using std::tr1::shared_ptr;
+
+#pragma db object
+class person
+{
+  ...
+};
+
+#pragma db object
+class account
+{
   ...
+
+  #pragma db value_not_null
+  std::vector<shared_ptr<person> > holders_;
 };
   
-

10.3.13 id_column

+

For set and multiset containers (Section 5.2, "Set and + Multiset Containers") the element value is automatically treated + as not allowing a NULL value.

+ +

10.3.14 id_column

The id_column specifier specifies the column name that should be used to store the object id in a @@ -6778,17 +6915,16 @@ private: class person { ... -private: + #pragma db id_column("person_id") std::vector<std::string> nicknames_; - ... };

If the column name is not specified, then object_id is used by default.

-

10.3.14 index_column

+

10.3.15 index_column

The index_column specifier specifies the column name that should be used to store the element index in an @@ -6803,17 +6939,16 @@ private: class person { ... -private: + #pragma db index_column("nickname_number") std::vector<std::string> nicknames_; - ... };

If the column name is not specified, then index is used by default.

-

10.3.15 key_column

+

10.3.16 key_column

The key_column specifier specifies the column name that should be used to store the key in a map @@ -6828,17 +6963,16 @@ private: class person { ... -private: + #pragma db key_column("age") std::map<unsigned short, float> age_weight_map_; - ... };

If the column name is not specified, then key is used by default.

-

10.3.16 value_column

+

10.3.17 value_column

The value_column specifier specifies the column name that should be used to store the element value in a @@ -6853,10 +6987,9 @@ private: class person { ... -private: + #pragma db value_column("weight") std::map<unsigned short, float> age_weight_map_; - ... }; @@ -6888,10 +7021,9 @@ PRAGMA_DB(object) class person { ... -private: + PRAGMA_DB(id) unsigned long id_; - ... }; @@ -6904,9 +7036,8 @@ private: class person { ... -private: + unsigned long id_; - ... }; #ifdef ODB_COMPILER @@ -6956,10 +7087,9 @@ g++ -Wall -Wno-unknown-pragmas ... class person { ... -private: + #pragma db id unsigned long id_; - ... }; #pragma warning (pop) @@ -7045,81 +7175,97 @@ aCC +W2161 ... C++ Type MySQL Type + Default NULL Semantics bool - TINYINT(1) NOT NULL + TINYINT(1) + NOT NULL char - TINYINT NOT NULL + TINYINT + NOT NULL signed char - TINYINT NOT NULL + TINYINT + NOT NULL unsigned char - TINYINT UNSIGNED NOT NULL + TINYINT UNSIGNED + NOT NULL short - SMALLINT NOT NULL + SMALLINT + NOT NULL unsigned short - SMALLINT UNSIGNED NOT NULL + SMALLINT UNSIGNED + NOT NULL int - INT NOT NULL + INT + NOT NULL unsigned int - INT UNSIGNED NOT NULL + INT UNSIGNED + NOT NULL long - BIGINT NOT NULL + BIGINT + NOT NULL unsigned long - BIGINT UNSIGNED NOT NULL + BIGINT UNSIGNED + NOT NULL long long - BIGINT NOT NULL + BIGINT + NOT NULL unsigned long long - BIGINT UNSIGNED NOT NULL + BIGINT UNSIGNED + NOT NULL float - FLOAT NOT NULL + FLOAT + NOT NULL double - DOUBLE NOT NULL + DOUBLE + NOT NULL std::string - TEXT NOT NULL/VARCHAR(255) NOT NULL + TEXT/VARCHAR(255) + NOT NULL @@ -7127,14 +7273,15 @@ aCC +W2161 ... differently depending on whether the member of this type is an object id or not. If the member is an object id, then for this member std::string is mapped - to the VARCHAR(255) NOT NULL MySQL type. Otherwise, - it is mapped to TEXT NOT NULL.

+ to the VARCHAR(255) MySQL type. Otherwise, + it is mapped to TEXT.

Additionally, by default, C++ enumerations are automatically mapped to a suitable MySQL type. Contiguous enumerations with - the zero first enumerator are mapped to the MySQL ENUM NOT - NULL type. All other enumerations are mapped to INT - NOT NULL or INT UNSIGNED NOT NULL. For example:

+ the zero first enumerator are mapped to the MySQL ENUM + type. All other enumerations are mapped to INT or + INT UNSIGNED. In both cases the default NULL + semantics is NOT NULL. For example:

 enum color {red, green, blue};
@@ -7540,86 +7687,103 @@ namespace odb
     
       C++ Type
       SQLite Type
+      Default NULL Semantics
     
 
     
       bool
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       char
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       signed char
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       unsigned char
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       short
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       unsigned short
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       int
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       unsigned int
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       long
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       unsigned long
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       long long
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       unsigned long long
-      INTEGER NOT NULL
+      INTEGER
+      NOT NULL
     
 
     
       float
-      REAL NOT NULL
+      REAL
+      NOT NULL
     
 
     
       double
-      REAL NOT NULL
+      REAL
+      NOT NULL
     
 
     
       std::string
-      TEXT NOT NULL
+      TEXT
+      NOT NULL
     
   
 
   

Additionally, by default, C++ enumerations are automatically mapped to - the SQLite INTEGER NOT NULL type.

+ the SQLite INTEGER type with the default NULL + semantics being NOT NULL.

Note also that SQLite only operates with signed integers and the largest value that an SQLite database can store is a signed 64-bit integer. As @@ -8073,86 +8237,103 @@ class person C++ Type PostgreSQL Type + Default NULL Semantics bool - BOOLEAN NOT NULL + BOOLEAN + NOT NULL char - SMALLINT NOT NULL + SMALLINT + NOT NULL signed char - SMALLINT NOT NULL + SMALLINT + NOT NULL unsigned char - SMALLINT NOT NULL + SMALLINT + NOT NULL short SMALLINT NULL + NOT NULL unsigned short - SMALLINT NOT NULL + SMALLINT + NOT NULL int - INTEGER NOT NULL + INTEGER + NOT NULL unsigned int - INTEGER NOT NULL + INTEGER + NOT NULL long - BIGINT NOT NULL + BIGINT + NOT NULL unsigned long - BIGINT NOT NULL + BIGINT + NOT NULL long long - BIGINT NOT NULL + BIGINT + NOT NULL unsigned long long - BIGINT NOT NULL + BIGINT + NOT NULL float - REAL NOT NULL + REAL + NOT NULL double - DOUBLE PRECISION NOT NULL + DOUBLE PRECISION + NOT NULL std::string - TEXT NOT NULL + TEXT + NOT NULL

Additionally, by default, C++ enumerations are automatically - mapped to INTEGER NOT NULL.

+ mapped to INTEGER with the default NULL + semantics being NOT NULL.

Note also that because PostgreSQL does not support unsigned integers, the unsigned short, unsigned int, and @@ -8815,21 +8996,25 @@ namespace odb Boost date_time Type MySQL Type + Default NULL Semantics gregorian::date DATE + NULL posix_time::ptime DATETIME + NULL posix_time::time_duration TIME + NULL @@ -8848,7 +9033,7 @@ namespace odb class person { ... - #pragma db type("TIMESTAMP") + #pragma db type("TIMESTAMP") not_null boost::posix_time::ptime updated_; };

@@ -8872,21 +9057,25 @@ class person Boost date_time Type SQLite Type + Default NULL Semantics gregorian::date TEXT + NULL posix_time::ptime TEXT + NULL posix_time::time_duration TEXT + NULL @@ -8997,16 +9186,19 @@ class Person Qt Type MySQL Type + Default NULL Semantics QString - TEXT + TEXT/VARCHAR(255) + NULL QByteArray BLOB + NULL @@ -9018,7 +9210,7 @@ class Person differently depending on whether the member of this type is an object id or not. If the member is an object id, then for this member QString is mapped - to the VARCHAR(255) NOT NULL MySQL type. Otherwise, + to the VARCHAR(255) MySQL type. Otherwise, it is mapped to TEXT.

@@ -9032,16 +9224,19 @@ class Person Qt Type SQLite Type + Default NULL Semantics QString TEXT + NULL QByteArray BLOB + NULL @@ -9189,21 +9384,25 @@ namespace odb Qt Date Time Type MySQL Type + Default NULL Semantics QDate DATE + NULL QTime TIME + NULL QDateTime DATETIME + NULL @@ -9223,7 +9422,7 @@ namespace odb class Person { ... - #pragma db type("TIMESTAMP") + #pragma db type("TIMESTAMP") not_null QDateTime updated_; }; @@ -9244,21 +9443,25 @@ class Person Qt Date Time Type SQLite Type + Default NULL Semantics QDate TEXT + NULL QTime TEXT + NULL QDateTime TEXT + NULL -- cgit v1.1