diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-16 16:03:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-16 16:03:25 +0200 |
commit | 2a270b8424d91e58b17b5d5f77ce9f135198569a (patch) | |
tree | da5414edd881e55823f5c425801d361d219e6ed9 /odb/mysql/query.hxx | |
parent | 7fec1734882ab0bf92ee1d21d898d7ee3d8f07bf (diff) |
Support for views; integrated part
Diffstat (limited to 'odb/mysql/query.hxx')
-rw-r--r-- | odb/mysql/query.hxx | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/odb/mysql/query.hxx b/odb/mysql/query.hxx index 57d43a1..4314938 100644 --- a/odb/mysql/query.hxx +++ b/odb/mysql/query.hxx @@ -106,6 +106,23 @@ namespace odb { } + // True or false literal. + // + explicit + query (bool v) + : binding_ (0, 0) + { + clause_.push_back ( + clause_part (clause_part::native, v ? "TRUE" : "FALSE")); + } + + explicit + query (const char* native) + : binding_ (0, 0) + { + clause_.push_back (clause_part (clause_part::native, native)); + } + explicit query (const std::string& native) : binding_ (0, 0) @@ -147,6 +164,9 @@ namespace odb std::string clause () const; + const char* + clause_prefix () const; + binding& parameters_binding () const; @@ -1031,6 +1051,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> @@ -1801,6 +1860,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) { |