From c1877f84f3596f67245abe6658b08c050bd1e686 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 4 Sep 2012 11:22:07 +0200 Subject: NULL handling improvements Add support for specifying NULL-ness for types with built-in mapping. Handle Oracle [N]VARCHAR2 and SQLite FLOAT oddities using this mechanism instead of overriding it at the schema generation level. Also use the is_null argument that is passed to value_traits::init_image() to indicate whether the value can be NULL. --- odb/relational/pgsql/context.cxx | 44 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'odb/relational/pgsql/context.cxx') diff --git a/odb/relational/pgsql/context.cxx b/odb/relational/pgsql/context.cxx index bed0d1a..391c65e 100644 --- a/odb/relational/pgsql/context.cxx +++ b/odb/relational/pgsql/context.cxx @@ -21,38 +21,39 @@ namespace relational { struct type_map_entry { - const char* const cxx_type; - const char* const db_type; - const char* const db_id_type; + char const* const cxx_type; + char const* const db_type; + char const* const db_id_type; + bool const null; }; type_map_entry type_map[] = { - {"bool", "BOOLEAN", 0}, + {"bool", "BOOLEAN", 0, false}, - {"char", "SMALLINT", 0}, - {"signed char", "SMALLINT", 0}, - {"unsigned char", "SMALLINT", 0}, + {"char", "SMALLINT", 0, false}, + {"signed char", "SMALLINT", 0, false}, + {"unsigned char", "SMALLINT", 0, false}, - {"short int", "SMALLINT", 0}, - {"short unsigned int", "SMALLINT", 0}, + {"short int", "SMALLINT", 0, false}, + {"short unsigned int", "SMALLINT", 0, false}, - {"int", "INTEGER", 0}, - {"unsigned int", "INTEGER", 0}, + {"int", "INTEGER", 0, false}, + {"unsigned int", "INTEGER", 0, false}, - {"long int", "BIGINT", 0}, - {"long unsigned int", "BIGINT", 0}, + {"long int", "BIGINT", 0, false}, + {"long unsigned int", "BIGINT", 0, false}, - {"long long int", "BIGINT", 0}, - {"long long unsigned int", "BIGINT", 0}, + {"long long int", "BIGINT", 0, false}, + {"long long unsigned int", "BIGINT", 0, false}, - {"float", "REAL", 0}, - {"double", "DOUBLE PRECISION", 0}, + {"float", "REAL", 0, false}, + {"double", "DOUBLE PRECISION", 0, false}, - {"::std::string", "TEXT", 0}, + {"::std::string", "TEXT", 0, false}, - {"::size_t", "BIGINT", 0}, - {"::std::size_t", "BIGINT", 0} + {"::size_t", "BIGINT", 0, false}, + {"::std::size_t", "BIGINT", 0, false} }; } @@ -94,7 +95,8 @@ namespace relational type_map_type::value_type v ( e.cxx_type, - db_type_type (e.db_type, e.db_id_type ? e.db_id_type : e.db_type)); + db_type_type ( + e.db_type, e.db_id_type ? e.db_id_type : e.db_type, e.null)); data_->type_map_.insert (v); } -- cgit v1.1