diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-21 11:07:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-21 11:09:27 +0200 |
commit | b69ec982bc3b417f026e4828e0b16b37b64b5841 (patch) | |
tree | 87802feecf192f81a1eb664380994fafdfbd5a3c /odb/mysql/query.txx | |
parent | c959c945cc0930623fbd0960fe6bd2f072dcbb5d (diff) |
Add support for pattern matching (SQL LIKE)
Diffstat (limited to 'odb/mysql/query.txx')
-rw-r--r-- | odb/mysql/query.txx | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/odb/mysql/query.txx b/odb/mysql/query.txx index 2aeaf8c..8c1665f 100644 --- a/odb/mysql/query.txx +++ b/odb/mysql/query.txx @@ -6,6 +6,7 @@ namespace odb { namespace mysql { + // // query_base // @@ -22,8 +23,12 @@ namespace odb append<bool, ID> (val_bind<bool> (true), c.conversion ()); } + // // query_column // + + // in + // template <typename T, database_type_id ID> query_base query_column<T, ID>:: in (decayed_type v1, decayed_type v2) const @@ -109,5 +114,51 @@ namespace odb q += ")"; return q; } + + // like + // + template <typename T, database_type_id ID> + query_base query_column<T, ID>:: + like (val_bind<T> p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append<T, ID> (p, conversion_); + return q; + } + + template <typename T, database_type_id ID> + query_base query_column<T, ID>:: + like (ref_bind<T> p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append<T, ID> (p, conversion_); + return q; + } + + template <typename T, database_type_id ID> + query_base query_column<T, ID>:: + like (val_bind<T> p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append<T, ID> (p, conversion_); + q += "ESCAPE"; + q.append<T, ID> (val_bind<T> (e), conversion_); + return q; + } + + template <typename T, database_type_id ID> + query_base query_column<T, ID>:: + like (ref_bind<T> p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append<T, ID> (p, conversion_); + q += "ESCAPE"; + q.append<T, ID> (val_bind<T> (e), conversion_); + return q; + } } } |