summaryrefslogtreecommitdiff
path: root/odb/mysql/query.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-01-24 15:10:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-01-24 15:10:21 +0200
commitc0f11dd9391fc84ca2554af122d672cb9af3531f (patch)
treedc81cddb4f34f1a3e2cd06f637f7cc4ab187d2ae /odb/mysql/query.hxx
parent1c15805b50657dc511428643d0822f359e79538c (diff)
Add support for mapping char[N] to CHAR/VARCHAR database types
Also improve query support for arrays (decaying).
Diffstat (limited to 'odb/mysql/query.hxx')
-rw-r--r--odb/mysql/query.hxx397
1 files changed, 279 insertions, 118 deletions
diff --git a/odb/mysql/query.hxx b/odb/mysql/query.hxx
index b86818e..5af564b 100644
--- a/odb/mysql/query.hxx
+++ b/odb/mysql/query.hxx
@@ -32,23 +32,72 @@ namespace odb
namespace mysql
{
template <typename T>
- class val_bind
+ struct val_bind
{
- public:
+ typedef const T& type;
+
+ explicit
+ val_bind (type v): val (v) {}
+
+ type val;
+ };
+
+ template <typename T, std::size_t N>
+ struct val_bind<T[N]>
+ {
+ typedef const T* type;
+
explicit
- val_bind (const T& v): val (v) {}
+ val_bind (type v): val (v) {}
- const T& val;
+ type val;
};
template <typename T>
- class ref_bind
+ struct ref_bind
+ {
+ typedef const T& type;
+
+ explicit
+ ref_bind (type r): ref (r) {}
+
+ const void*
+ ptr () const {return &ref;}
+
+ type ref;
+ };
+
+ template <typename T, std::size_t N>
+ struct ref_bind<T[N]>
+ {
+ typedef const T* type;
+
+ explicit
+ ref_bind (type r): ref (r) {}
+
+ // Allow implicit conversion from decayed ref_bind's.
+ //
+ ref_bind (ref_bind<T*> r): ref (r.ref) {}
+ ref_bind (ref_bind<const T*> r): ref (r.ref) {}
+
+ const void*
+ ptr () const {return ref;}
+
+ type ref;
+ };
+
+ template <typename T, database_type_id ID>
+ struct val_bind_typed: val_bind<T>
{
- public:
explicit
- ref_bind (const T& r): ref (r) {}
+ val_bind_typed (typename val_bind<T>::type v): val_bind<T> (v) {}
+ };
- const T& ref;
+ template <typename T, database_type_id ID>
+ struct ref_bind_typed: ref_bind<T>
+ {
+ explicit
+ ref_bind_typed (typename ref_bind<T>::type r): ref_bind<T> (r) {}
};
struct LIBODB_MYSQL_EXPORT query_param: details::shared_base
@@ -69,10 +118,7 @@ namespace odb
bind (MYSQL_BIND*) = 0;
protected:
- query_param (const void* value)
- : value_ (value)
- {
- }
+ query_param (const void* value) : value_ (value) {}
protected:
const void* value_;
@@ -144,8 +190,15 @@ namespace odb
query_base (val_bind<T> v)
: binding_ (0, 0)
{
- append<T, type_traits<T>::db_type_id> (
- v, details::conversion<T>::to ());
+ *this += v;
+ }
+
+ template <typename T, database_type_id ID>
+ explicit
+ query_base (val_bind_typed<T, ID> v)
+ : binding_ (0, 0)
+ {
+ *this += v;
}
template <typename T>
@@ -153,8 +206,15 @@ namespace odb
query_base (ref_bind<T> r)
: binding_ (0, 0)
{
- append<T, type_traits<T>::db_type_id> (
- r, details::conversion<T>::to ());
+ *this += r;
+ }
+
+ template <typename T, database_type_id ID>
+ explicit
+ query_base (ref_bind_typed<T, ID> r)
+ : binding_ (0, 0)
+ {
+ *this += r;
}
template <database_type_id ID>
@@ -215,6 +275,13 @@ namespace odb
return val_bind<T> (x);
}
+ template <database_type_id ID, typename T>
+ static val_bind_typed<T, ID>
+ _val (const T& x)
+ {
+ return val_bind_typed<T, ID> (x);
+ }
+
template <typename T>
static ref_bind<T>
_ref (const T& x)
@@ -222,6 +289,13 @@ namespace odb
return ref_bind<T> (x);
}
+ template <database_type_id ID, typename T>
+ static ref_bind_typed<T, ID>
+ _ref (const T& x)
+ {
+ return ref_bind_typed<T, ID> (x);
+ }
+
public:
query_base&
operator+= (const query_base&);
@@ -242,6 +316,17 @@ namespace odb
return *this;
}
+ template <typename T, database_type_id ID>
+ query_base&
+ operator+= (val_bind_typed<T, ID> v)
+ {
+ // We are not using default type_traits so no default conversion
+ // either.
+ //
+ append<T, ID> (v, 0);
+ return *this;
+ }
+
template <typename T>
query_base&
operator+= (ref_bind<T> r)
@@ -251,6 +336,17 @@ namespace odb
return *this;
}
+ template <typename T, database_type_id ID>
+ query_base&
+ operator+= (ref_bind_typed<T, ID> r)
+ {
+ // We are not using default type_traits so no default conversion
+ // either.
+ //
+ append<T, ID> (r, 0);
+ return *this;
+ }
+
// Implementation details.
//
public:
@@ -312,16 +408,26 @@ namespace odb
template <typename T>
inline query_base
- operator+ (const query_base& q, ref_bind<T> b)
+ operator+ (val_bind<T> b, const query_base& q)
+ {
+ query_base r;
+ r += b;
+ r += q;
+ return r;
+ }
+
+ template <typename T, database_type_id ID>
+ inline query_base
+ operator+ (const query_base& q, val_bind_typed<T, ID> b)
{
query_base r (q);
r += b;
return r;
}
- template <typename T>
+ template <typename T, database_type_id ID>
inline query_base
- operator+ (val_bind<T> b, const query_base& q)
+ operator+ (val_bind_typed<T, ID> b, const query_base& q)
{
query_base r;
r += b;
@@ -331,6 +437,15 @@ namespace odb
template <typename T>
inline query_base
+ operator+ (const query_base& q, ref_bind<T> b)
+ {
+ query_base r (q);
+ r += b;
+ return r;
+ }
+
+ template <typename T>
+ inline query_base
operator+ (ref_bind<T> b, const query_base& q)
{
query_base r;
@@ -339,6 +454,25 @@ namespace odb
return r;
}
+ template <typename T, database_type_id ID>
+ inline query_base
+ operator+ (const query_base& q, ref_bind_typed<T, ID> b)
+ {
+ query_base r (q);
+ r += b;
+ return r;
+ }
+
+ template <typename T, database_type_id ID>
+ inline query_base
+ operator+ (ref_bind_typed<T, ID> b, const query_base& q)
+ {
+ query_base r;
+ r += b;
+ r += q;
+ return r;
+ }
+
inline query_base
operator+ (const query_base& q, const std::string& s)
{
@@ -366,16 +500,26 @@ namespace odb
template <typename T>
inline query_base
- operator+ (const std::string& s, ref_bind<T> b)
+ operator+ (val_bind<T> b, const std::string& s)
+ {
+ query_base r;
+ r += b;
+ r += s;
+ return r;
+ }
+
+ template <typename T, database_type_id ID>
+ inline query_base
+ operator+ (const std::string& s, val_bind_typed<T, ID> b)
{
query_base r (s);
r += b;
return r;
}
- template <typename T>
+ template <typename T, database_type_id ID>
inline query_base
- operator+ (val_bind<T> b, const std::string& s)
+ operator+ (val_bind_typed<T, ID> b, const std::string& s)
{
query_base r;
r += b;
@@ -385,6 +529,15 @@ namespace odb
template <typename T>
inline query_base
+ operator+ (const std::string& s, ref_bind<T> b)
+ {
+ query_base r (s);
+ r += b;
+ return r;
+ }
+
+ template <typename T>
+ inline query_base
operator+ (ref_bind<T> b, const std::string& s)
{
query_base r;
@@ -393,6 +546,25 @@ namespace odb
return r;
}
+ template <typename T, database_type_id ID>
+ inline query_base
+ operator+ (const std::string& s, ref_bind_typed<T, ID> b)
+ {
+ query_base r (s);
+ r += b;
+ return r;
+ }
+
+ template <typename T, database_type_id ID>
+ inline query_base
+ operator+ (ref_bind_typed<T, ID> b, const std::string& s)
+ {
+ query_base r;
+ r += b;
+ r += s;
+ return r;
+ }
+
LIBODB_MYSQL_EXPORT query_base
operator&& (const query_base& x, const query_base& y);
@@ -442,23 +614,11 @@ namespace odb
const char* conversion_;
};
- template <typename T, typename T2>
- class copy_bind: public val_bind<T>
- {
- public:
- explicit
- copy_bind (const T2& v): val_bind<T> (val), val (v) {}
-
- const T val;
- };
-
- template <typename T>
- const T&
- type_instance ();
-
template <typename T, database_type_id ID>
struct query_column: query_column_base
{
+ typedef typename decay_traits<T>::type decayed_type;
+
// Note that we keep shallow copies of the table, column, and conversion
// expression. The latter can be NULL.
//
@@ -493,16 +653,17 @@ namespace odb
//
public:
query_base
- in (const T&, const T&) const;
+ in (decayed_type, decayed_type) const;
query_base
- in (const T&, const T&, const T&) const;
+ in (decayed_type, decayed_type, decayed_type) const;
query_base
- in (const T&, const T&, const T&, const T&) const;
+ in (decayed_type, decayed_type, decayed_type, decayed_type) const;
query_base
- in (const T&, const T&, const T&, const T&, const T&) const;
+ in (decayed_type, decayed_type, decayed_type, decayed_type,
+ decayed_type) const;
template <typename I>
query_base
@@ -512,7 +673,7 @@ namespace odb
//
public:
query_base
- equal (const T& v) const
+ equal (decayed_type v) const
{
return equal (val_bind<T> (v));
}
@@ -530,8 +691,7 @@ namespace odb
query_base
equal (val_bind<T2> v) const
{
- copy_bind<T, T2> c (v.val);
- return equal (c);
+ return equal (val_bind<T> (decayed_type (v.val)));
}
query_base
@@ -544,13 +704,13 @@ namespace odb
}
friend query_base
- operator== (const query_column& c, const T& v)
+ operator== (const query_column& c, decayed_type v)
{
return c.equal (v);
}
friend query_base
- operator== (const T& v, const query_column& c)
+ operator== (decayed_type v, const query_column& c)
{
return c.equal (v);
}
@@ -597,7 +757,7 @@ namespace odb
//
public:
query_base
- unequal (const T& v) const
+ unequal (decayed_type v) const
{
return unequal (val_bind<T> (v));
}
@@ -615,8 +775,7 @@ namespace odb
query_base
unequal (val_bind<T2> v) const
{
- copy_bind<T, T2> c (v.val);
- return unequal (c);
+ return unequal (val_bind<T> (decayed_type (v.val)));
}
query_base
@@ -629,13 +788,13 @@ namespace odb
}
friend query_base
- operator!= (const query_column& c, const T& v)
+ operator!= (const query_column& c, decayed_type v)
{
return c.unequal (v);
}
friend query_base
- operator!= (const T& v, const query_column& c)
+ operator!= (decayed_type v, const query_column& c)
{
return c.unequal (v);
}
@@ -682,7 +841,7 @@ namespace odb
//
public:
query_base
- less (const T& v) const
+ less (decayed_type v) const
{
return less (val_bind<T> (v));
}
@@ -700,8 +859,7 @@ namespace odb
query_base
less (val_bind<T2> v) const
{
- copy_bind<T, T2> c (v.val);
- return less (c);
+ return less (val_bind<T> (decayed_type (v.val)));
}
query_base
@@ -714,13 +872,13 @@ namespace odb
}
friend query_base
- operator< (const query_column& c, const T& v)
+ operator< (const query_column& c, decayed_type v)
{
return c.less (v);
}
friend query_base
- operator< (const T& v, const query_column& c)
+ operator< (decayed_type v, const query_column& c)
{
return c.greater (v);
}
@@ -767,7 +925,7 @@ namespace odb
//
public:
query_base
- greater (const T& v) const
+ greater (decayed_type v) const
{
return greater (val_bind<T> (v));
}
@@ -785,8 +943,7 @@ namespace odb
query_base
greater (val_bind<T2> v) const
{
- copy_bind<T, T2> c (v.val);
- return greater (c);
+ return greater (val_bind<T> (decayed_type (v.val)));
}
query_base
@@ -799,13 +956,13 @@ namespace odb
}
friend query_base
- operator> (const query_column& c, const T& v)
+ operator> (const query_column& c, decayed_type v)
{
return c.greater (v);
}
friend query_base
- operator> (const T& v, const query_column& c)
+ operator> (decayed_type v, const query_column& c)
{
return c.less (v);
}
@@ -852,7 +1009,7 @@ namespace odb
//
public:
query_base
- less_equal (const T& v) const
+ less_equal (decayed_type v) const
{
return less_equal (val_bind<T> (v));
}
@@ -870,8 +1027,7 @@ namespace odb
query_base
less_equal (val_bind<T2> v) const
{
- copy_bind<T, T2> c (v.val);
- return less_equal (c);
+ return less_equal (val_bind<T> (decayed_type (v.val)));
}
query_base
@@ -884,13 +1040,13 @@ namespace odb
}
friend query_base
- operator<= (const query_column& c, const T& v)
+ operator<= (const query_column& c, decayed_type v)
{
return c.less_equal (v);
}
friend query_base
- operator<= (const T& v, const query_column& c)
+ operator<= (decayed_type v, const query_column& c)
{
return c.greater_equal (v);
}
@@ -937,7 +1093,7 @@ namespace odb
//
public:
query_base
- greater_equal (const T& v) const
+ greater_equal (decayed_type v) const
{
return greater_equal (val_bind<T> (v));
}
@@ -955,8 +1111,7 @@ namespace odb
query_base
greater_equal (val_bind<T2> v) const
{
- copy_bind<T, T2> c (v.val);
- return greater_equal (c);
+ return greater_equal (val_bind<T> (decayed_type (v.val)));
}
query_base
@@ -969,13 +1124,13 @@ namespace odb
}
friend query_base
- operator>= (const query_column& c, const T& v)
+ operator>= (const query_column& c, decayed_type v)
{
return c.greater_equal (v);
}
friend query_base
- operator>= (const T& v, const query_column& c)
+ operator>= (decayed_type v, const query_column& c)
{
return c.less_equal (v);
}
@@ -1027,7 +1182,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () == type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () ==
+ decay_traits<T2>::instance ()));
query_base q (table_, column_);
q += "=";
@@ -1041,7 +1197,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () != type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () !=
+ decay_traits<T2>::instance ()));
query_base q (table_, column_);
q += "!=";
@@ -1055,7 +1212,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () < type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () <
+ decay_traits<T2>::instance ()));
query_base q (table_, column_);
q += "<";
@@ -1069,7 +1227,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () > type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () >
+ decay_traits<T2>::instance ()));
query_base q (table_, column_);
q += ">";
@@ -1083,7 +1242,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () <= type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () <=
+ decay_traits<T2>::instance ()));
query_base q (table_, column_);
q += "<=";
@@ -1097,7 +1257,8 @@ namespace odb
{
// We can compare columns only if we can compare their C++ types.
//
- (void) (sizeof (type_instance<T> () >= type_instance<T2> ()));
+ (void) (sizeof (decay_traits<T>::instance () >=
+ decay_traits<T2>::instance ()));
query_base q (table_, column_);
q += ">=";
@@ -1155,7 +1316,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_tiny>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1175,7 +1336,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_tiny>::set_image (image_, is_null, v);
@@ -1188,7 +1349,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_utiny>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1208,7 +1369,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_utiny>::set_image (image_, is_null, v);
@@ -1223,7 +1384,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_short>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1243,7 +1404,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_short>::set_image (image_, is_null, v);
@@ -1256,7 +1417,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_ushort>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1276,7 +1437,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_ushort>::set_image (image_, is_null, v);
@@ -1291,7 +1452,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_long>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1311,7 +1472,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_long>::set_image (image_, is_null, v);
@@ -1324,7 +1485,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_ulong>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1344,7 +1505,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_ulong>::set_image (image_, is_null, v);
@@ -1359,7 +1520,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_longlong>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1379,7 +1540,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_longlong>::set_image (image_, is_null, v);
@@ -1392,7 +1553,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_ulonglong>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1412,7 +1573,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_ulonglong>::set_image (image_, is_null, v);
@@ -1427,7 +1588,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_float>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1447,7 +1608,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_float>::set_image (image_, is_null, v);
@@ -1462,7 +1623,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_double>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1482,7 +1643,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_double>::set_image (image_, is_null, v);
@@ -1497,7 +1658,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_decimal>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1517,7 +1678,7 @@ namespace odb
private:
bool
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
std::size_t size (0), cap (buffer_.capacity ());
@@ -1536,7 +1697,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_date>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1555,7 +1716,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_date>::set_image (image_, is_null, v);
@@ -1570,7 +1731,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_time>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1589,7 +1750,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_time>::set_image (image_, is_null, v);
@@ -1604,7 +1765,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_datetime>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1623,7 +1784,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_datetime>::set_image (image_, is_null, v);
@@ -1638,7 +1799,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_timestamp>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1657,7 +1818,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_timestamp>::set_image (image_, is_null, v);
@@ -1672,7 +1833,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_year>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1692,7 +1853,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
value_traits<T, id_year>::set_image (image_, is_null, v);
@@ -1707,7 +1868,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_string>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1727,7 +1888,7 @@ namespace odb
private:
bool
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
std::size_t size (0), cap (buffer_.capacity ());
@@ -1746,7 +1907,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_blob>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1766,7 +1927,7 @@ namespace odb
private:
bool
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
std::size_t size (0), cap (buffer_.capacity ());
@@ -1785,7 +1946,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_bit>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1806,7 +1967,7 @@ namespace odb
private:
void
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
std::size_t size (0);
@@ -1829,7 +1990,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_enum>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1846,7 +2007,7 @@ namespace odb
private:
bool
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
return enum_traits::set_image (image_, size_, is_null, v);
@@ -1862,7 +2023,7 @@ namespace odb
template <typename T>
struct query_param_impl<T, id_set>: query_param
{
- query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool
@@ -1882,7 +2043,7 @@ namespace odb
private:
bool
- init (const T& v)
+ init (typename decay_traits<T>::type v)
{
bool is_null (false); // Can't be NULL.
std::size_t size (0), cap (buffer_.capacity ());