aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/query.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-21 11:07:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-21 11:09:39 +0200
commitb580f1548ff335a0e1fa004fc6626486535c94e1 (patch)
tree221ddaf79fce6136e6a8db8de0c81528ac24964a /odb/sqlite/query.txx
parent7e88b0a80618848d3a3c5f6cad886c8b7785787d (diff)
Add support for pattern matching (SQL LIKE)
Diffstat (limited to 'odb/sqlite/query.txx')
-rw-r--r--odb/sqlite/query.txx51
1 files changed, 51 insertions, 0 deletions
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<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;
+ }
}
}