From c970a38889d5774f7d0f73215dfd70934524d76a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 10 Jul 2012 15:17:13 +0200 Subject: Add support for custom database type mapping New pragma qualifier, map, and specifiers: as, to, from. New tests: /custom. --- odb/mysql/query.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'odb/mysql/query.cxx') diff --git a/odb/mysql/query.cxx b/odb/mysql/query.cxx index 2573ac1..70d55c2 100644 --- a/odb/mysql/query.cxx +++ b/odb/mysql/query.cxx @@ -118,10 +118,13 @@ namespace odb } void query:: - add (details::shared_ptr p) + add (details::shared_ptr p, const char* conv) { clause_.push_back (clause_part (clause_part::param)); + if (conv != 0) + clause_.back ().part = conv; + parameters_.push_back (p); bind_.push_back (MYSQL_BIND ()); binding_.bind = &bind_[0]; @@ -258,7 +261,20 @@ namespace odb if (last != ' ' && last != '(') r += ' '; + // Add the conversion expression, if any. + // + string::size_type p; + if (!i->part.empty ()) + { + p = i->part.find ("(?)"); + r.append (i->part, 0, p); + } + r += '?'; + + if (!i->part.empty ()) + r.append (i->part, p + 3, string::npos); + break; } case clause_part::native: -- cgit v1.1