aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/query.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-19 14:08:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-19 14:08:16 +0200
commit6e3ac760696d4ec43138b1aba82426582c767072 (patch)
tree00c30ed11c75b4f2d9daf1ebb85c026a90658129 /odb/pgsql/query.txx
parent7391841a063328828621c8b70e02a81674686c97 (diff)
Rework query machinery not to use '_' as primary table alias
Now we always qualify with the actual table name and use the '_' alias for situations where an object is referencing itself.
Diffstat (limited to 'odb/pgsql/query.txx')
-rw-r--r--odb/pgsql/query.txx16
1 files changed, 9 insertions, 7 deletions
diff --git a/odb/pgsql/query.txx b/odb/pgsql/query.txx
index 7d80f2b..6fdc4fe 100644
--- a/odb/pgsql/query.txx
+++ b/odb/pgsql/query.txx
@@ -13,12 +13,14 @@ namespace odb
template <database_type_id ID>
query::
query (const query_column<bool, ID>& c)
- : clause_ (c.name ()), binding_ (0, 0), native_binding_ (0, 0, 0, 0)
+ : binding_ (0, 0), native_binding_ (0, 0, 0, 0)
{
+ clause_.push_back (clause_part (clause_part::column, c.name ()));
+
// Cannot use IS TRUE here since database type can be a non-
// integral type.
//
- clause_ += " = ";
+ clause_.push_back (clause_part (clause_part::native, "="));
append<bool, ID> (val_bind<bool> (true));
}
@@ -28,7 +30,7 @@ namespace odb
query query_column<T, ID>::
in (const T& v1, const T& v2) const
{
- query q (name_);
+ query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
@@ -41,7 +43,7 @@ namespace odb
query query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3) const
{
- query q (name_);
+ query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
@@ -56,7 +58,7 @@ namespace odb
query query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3, const T& v4) const
{
- query q (name_);
+ query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
@@ -73,7 +75,7 @@ namespace odb
query query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) const
{
- query q (name_);
+ query q (name_, query::clause_part::column);
q += "IN (";
q.append<T, ID> (val_bind<T> (v1));
q += ",";
@@ -93,7 +95,7 @@ namespace odb
query query_column<T, ID>::
in_range (I begin, I end) const
{
- query q (name_);
+ query q (name_, query::clause_part::column);
q += "IN (";
for (I i (begin); i != end; ++i)