From b580f1548ff335a0e1fa004fc6626486535c94e1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Feb 2013 11:07:25 +0200 Subject: Add support for pattern matching (SQL LIKE) --- odb/sqlite/query.txx | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'odb/sqlite/query.txx') diff --git a/odb/sqlite/query.txx b/odb/sqlite/query.txx index b63d5a1..ed2e5b4 100644 --- a/odb/sqlite/query.txx +++ b/odb/sqlite/query.txx @@ -6,6 +6,7 @@ namespace odb { namespace sqlite { + // // query_base // @@ -22,8 +23,12 @@ namespace odb append (val_bind (true), c.conversion ()); } + // // query_column // + + // in + // template query_base query_column:: in (decayed_type v1, decayed_type v2) const @@ -109,5 +114,51 @@ namespace odb q += ")"; return q; } + + // like + // + template + query_base query_column:: + like (val_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + return q; + } + + template + query_base query_column:: + like (val_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } + + template + query_base query_column:: + like (ref_bind p, decayed_type e) const + { + query_base q (table_, column_); + q += "LIKE"; + q.append (p, conversion_); + q += "ESCAPE"; + q.append (val_bind (e), conversion_); + return q; + } } } -- cgit v1.1