From db71e956ea808569ce1e5bbcabb7e65dc4604ac8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Sep 2011 16:03:25 +0200 Subject: Support for views; integrated part --- odb/pgsql/query.hxx | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'odb/pgsql/query.hxx') 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 + inline query + operator+ (const query_column& c, const std::string& s) + { + query q (c.table (), c.column ()); + q += s; + return q; + } + + template + inline query + operator+ (const std::string& s, const query_column& c) + { + query q (s); + q.append (c.table (), c.column ()); + return q; + } + + template + inline query + operator+ (const query_column& c, const query& q) + { + query r (c.table (), c.column ()); + r += q; + return r; + } + + template + inline query + operator+ (const query& q, const query_column& c) + { + query r (q); + r.append (c.table (), c.column ()); + return r; + } + // // template @@ -1702,6 +1761,18 @@ namespace odb } explicit + query (bool v) + : query_selector::type (v) + { + } + + explicit + query (const char* q) + : query_selector::type (q) + { + } + + explicit query (const std::string& q) : query_selector::type (q) { -- cgit v1.1