aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/query.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-09-16 16:03:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-09-16 16:03:25 +0200
commit02aed5f059797cd5e53a9fe6dde13714f86332d4 (patch)
treeb2bfce8921184f8767dddba221032792b1cb3214 /odb/sqlite/query.hxx
parenta8b1a89c291ab5bd170568eab3d7666631adf035 (diff)
Support for views; integrated part
Diffstat (limited to 'odb/sqlite/query.hxx')
-rw-r--r--odb/sqlite/query.hxx70
1 files changed, 70 insertions, 0 deletions
diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx
index 9731d10..c712b58 100644
--- a/odb/sqlite/query.hxx
+++ b/odb/sqlite/query.hxx
@@ -136,6 +136,22 @@ namespace odb
{
}
+ // True or false literal.
+ //
+ explicit
+ query (bool v)
+ : parameters_ (new (details::shared) query_params)
+ {
+ clause_.push_back (clause_part (clause_part::native, v ? "1" : "0"));
+ }
+
+ explicit
+ query (const char* native)
+ : parameters_ (new (details::shared) query_params)
+ {
+ clause_.push_back (clause_part (clause_part::native, native));
+ }
+
explicit
query (const std::string& native)
: parameters_ (new (details::shared) query_params)
@@ -177,6 +193,9 @@ namespace odb
std::string
clause () const;
+ const char*
+ clause_prefix () const;
+
binding&
parameters_binding () const;
@@ -1061,6 +1080,45 @@ namespace odb
const char* column_;
};
+ // Provide operator+() for using columns to construct native
+ // query fragments (e.g., ORDER BY).
+ //
+ template <typename T, database_type_id ID>
+ inline query
+ operator+ (const query_column<T, ID>& c, const std::string& s)
+ {
+ query q (c.table (), c.column ());
+ q += s;
+ return q;
+ }
+
+ template <typename T, database_type_id ID>
+ inline query
+ operator+ (const std::string& s, const query_column<T, ID>& c)
+ {
+ query q (s);
+ q.append (c.table (), c.column ());
+ return q;
+ }
+
+ template <typename T, database_type_id ID>
+ inline query
+ operator+ (const query_column<T, ID>& c, const query& q)
+ {
+ query r (c.table (), c.column ());
+ r += q;
+ return r;
+ }
+
+ template <typename T, database_type_id ID>
+ inline query
+ operator+ (const query& q, const query_column<T, ID>& c)
+ {
+ query r (q);
+ r.append (c.table (), c.column ());
+ return r;
+ }
+
//
//
template <typename T, database_type_id>
@@ -1227,6 +1285,18 @@ namespace odb
}
explicit
+ query (bool v)
+ : query_selector<T>::type (v)
+ {
+ }
+
+ explicit
+ query (const char* q)
+ : query_selector<T>::type (q)
+ {
+ }
+
+ explicit
query (const std::string& q)
: query_selector<T>::type (q)
{