From a482f1c4dd4efab83d3b19309900f1cbf54383a5 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov Default values specified as enumerators are only supported for
members that are mapped to an ENUM
or an integer
type in the database, which is the case for the automatic
- mapping of C++ enums to suitable database types as performed
- by the ODB compiler. If you have mapped a C++ enum to another
- database type, then you should use a literal corresponding
- to that type to specify the default value. For example:
enum gender {male, female, undisclosed}; @@ -18670,16 +18671,18 @@ person.hxx to theVARCHAR(255)
MySQL type. Otherwise, it is mapped toTEXT
. -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
- type. All other enumerations are mapped toINT
or -INT UNSIGNED
. In both cases the defaultNULL
- semantics isNOT NULL
. For example:Additionally, by default, C++ enums and C++11 enum classes are + automatically mapped to suitable MySQL types. Contiguous + enumerations with the zero first enumerator are mapped to + the MySQL
ENUM
type. All other enumerations + are mapped to the MySQL types corresponding to their + underlying integral types (see table above). In both + cases the defaultNULL
semantics is +NOT NULL
. For example:enum color {red, green, blue}; -enum taste +enum class taste: unsigned char { bitter = 1, // Non-zero first enumerator. sweet, @@ -18693,7 +18696,7 @@ class object ... color color_; // Mapped to ENUM ('red', 'green', 'blue') NOT NULL. - taste taste_; // Mapped to INT UNSIGNED NOT NULL. + taste taste_; // Mapped to TINYNT UNSIGNED NOT NULL. };@@ -19433,9 +19436,30 @@ class objectdb not_null
pragma (Section 14.4.6, "null/not_null
"). -Additionally, by default, C++ enumerations are automatically mapped to - the SQLite
+INTEGER
type with the defaultNULL
- semantics beingNOT NULL
.Additionally, by default, C++ enums and C++11 enum classes are + automatically mapped to the SQLite
+ +INTEGER
type with + the defaultNULL
semantics beingNOT NULL
. + For example:+enum color {red, green, blue}; +enum class taste: unsigned char +{ + bitter = 1, + sweet, + sour = 4, + salty +}; + +#pragma db object +class object +{ + ... + + color color_; // Automatically mapped to INTEGER. + taste taste_; // Automatically mapped to INTEGER. +}; +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 @@ -20406,9 +20430,31 @@ class object
-db type
pragma (Section 14.4.3, "type
").Additionally, by default, C++ enumerations are automatically - mapped to
+INTEGER
with the defaultNULL
- semantics beingNOT NULL
.Additionally, by default, C++ enums and C++11 enum classes are + automatically mapped to the PostgreSQL types corresponding to their + underlying integral types (see table above). The default +
+ +NULL
semantics isNOT NULL
. For + example:+enum color {red, green, blue}; +enum class taste: unsigned char +{ + bitter = 1, + sweet, + sour = 4, + salty +}; + +#pragma db object +class object +{ + ... + + color color_; // Automatically mapped to INTEGER. + taste taste_; // Automatically mapped to SMALLINT. +}; +Note also that because PostgreSQL does not support unsigned integers, the
-unsigned short
,unsigned int
, and @@ -21174,9 +21220,31 @@ class object object ids that are mapped to these Oracle types, an empty string is an invalid value.Additionally, by default, C++ enumerations are automatically - mapped to
+NUMBER(10)
with the defaultNULL
- semantics beingNOT NULL
.Additionally, by default, C++ enums and C++11 enum classes are + automatically mapped to the Oracle types corresponding to their + underlying integral types (see table above). The default +
+ +NULL
semantics isNOT NULL
. For + example:+enum color {red, green, blue}; +enum class taste: unsigned char +{ + bitter = 1, + sweet, + sour = 4, + salty +}; + +#pragma db object +class object +{ + ... + + color color_; // Automatically mapped to NUMBER(10). + taste taste_; // Automatically mapped to NUMBER(3). +}; +It is also possible to add support for additional Oracle types, such as
-XML
, geospatial types, user-defined types, @@ -22114,9 +22182,31 @@ class object always change this mapping using thedb type
pragma (Section 14.4.3, "type
").Additionally, by default, C++ enumerations are automatically - mapped to
+INT
with the defaultNULL
- semantics beingNOT NULL
.Additionally, by default, C++ enums and C++11 enum classes are + automatically mapped to the SQL Server types corresponding to their + underlying integral types (see table above). The default +
+ +NULL
semantics isNOT NULL
. For + example:+enum color {red, green, blue}; +enum class taste: unsigned char +{ + bitter = 1, + sweet, + sour = 4, + salty +}; + +#pragma db object +class object +{ + ... + + color color_; // Automatically mapped to INT. + taste taste_; // Automatically mapped to TINYINT. +}; +Note also that because SQL Server does not support unsigned integers, the
unsigned short
,unsigned int
, and -- cgit v1.1