aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/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
commitdb71e956ea808569ce1e5bbcabb7e65dc4604ac8 (patch)
tree36361958211b842d21339566946d5a1680dde8d1 /odb/pgsql/query.hxx
parentdedd9690c67ff5577072162e6a3a5c8a7c843e17 (diff)
Support for views; integrated part
Diffstat (limited to 'odb/pgsql/query.hxx')
-rw-r--r--odb/pgsql/query.hxx71
1 files changed, 71 insertions, 0 deletions
diff --git a/odb/pgsql/query.hxx b/odb/pgsql/query.hxx
index 7fd66d7..438f2f5 100644
--- a/odb/pgsql/query.hxx
+++ b/odb/pgsql/query.hxx
@@ -110,6 +110,23 @@ namespace odb
{
}
+ // True or false literal.
+ //
+ explicit
+ query (bool v)
+ : binding_ (0, 0), native_binding_ (0, 0, 0, 0)
+ {
+ clause_.push_back (
+ clause_part (clause_part::native, v ? "TRUE" : "FALSE"));
+ }
+
+ explicit
+ query (const char* native)
+ : binding_ (0, 0), native_binding_ (0, 0, 0, 0)
+ {
+ clause_.push_back (clause_part (clause_part::native, native));
+ }
+
explicit
query (const std::string& native)
: binding_ (0, 0), native_binding_ (0, 0, 0, 0)
@@ -151,6 +168,9 @@ namespace odb
std::string
clause () const;
+ const char*
+ clause_prefix () const;
+
native_binding&
parameters_binding () const;
@@ -1054,6 +1074,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>
@@ -1702,6 +1761,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)
{