summaryrefslogtreecommitdiff
path: root/odb/relational/mysql/source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-07-10 15:17:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-07-10 15:17:16 +0200
commitb8554760aa3a5c5697c77d11e507a2bb46dbf8e4 (patch)
tree3f2bcb28a59eb0d4cce4586acec4a8c639cde7e6 /odb/relational/mysql/source.cxx
parent1b64460a2b2c5411b6052cd4c4d8e8b0d46a4086 (diff)
Add support for custom database type mapping
New pragma qualifier, map, and specifiers: as, to, from. New tests: <database>/custom.
Diffstat (limited to 'odb/relational/mysql/source.cxx')
-rw-r--r--odb/relational/mysql/source.cxx41
1 files changed, 14 insertions, 27 deletions
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));
}
};