From b8554760aa3a5c5697c77d11e507a2bb46dbf8e4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 10 Jul 2012 15:17:16 +0200 Subject: Add support for custom database type mapping New pragma qualifier, map, and specifiers: as, to, from. New tests: /custom. --- odb/relational/mysql/source.cxx | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'odb/relational/mysql/source.cxx') diff --git a/odb/relational/mysql/source.cxx b/odb/relational/mysql/source.cxx index 8591aca..15a4fcf 100644 --- a/odb/relational/mysql/source.cxx +++ b/odb/relational/mysql/source.cxx @@ -109,7 +109,7 @@ namespace relational // to value_traits. // - string type (column_type ()); + string const& type (column_type ()); if (sk_ != statement_select || parse_sql_type (type, m).type != sql_type::ENUM) @@ -118,28 +118,18 @@ namespace relational return; } - string r; - - r += "CONCAT("; - - if (!table.empty ()) - { - r += table; - r += '.'; - } - - r += column; - r += "+0,' ',"; - + // Qualified column and conversion expression. + // + string qc; if (!table.empty ()) { - r += table; - r += '.'; + qc += table; + qc += '.'; } + qc += column; + qc = convert_from (qc, type, m); - r += column; - - r += ")"; + string r ("CONCAT(" + qc + "+0,' '," + qc + ")"); sc_.push_back ( relational::statement_column (table, r, type, m, key_prefix_)); @@ -158,7 +148,7 @@ namespace relational { // The same idea as in object_columns. // - string type (column_type ()); + string const& type (column_type ()); if (parse_sql_type (type, m).type != sql_type::ENUM) { @@ -166,14 +156,11 @@ namespace relational return; } - string r; - - r += "CONCAT("; - r += column; - r += "+0,' ',"; - r += column; - r += ")"; + // Column and conversion expression. + // + string c (convert_from (column, type, m)); + string r ("CONCAT(" + c + "+0,' '," + c + ")"); sc_.push_back (relational::statement_column (table, r, type, m)); } }; -- cgit v1.1