From 47d344f31f7a1a980d807c142e0a36b09db3b1f3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Aug 2011 14:08:16 +0200 Subject: 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. --- odb/mysql/query.txx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'odb/mysql/query.txx') diff --git a/odb/mysql/query.txx b/odb/mysql/query.txx index 8cbe201..6addb65 100644 --- a/odb/mysql/query.txx +++ b/odb/mysql/query.txx @@ -13,12 +13,14 @@ namespace odb template query:: query (const query_column& c) - : clause_ (c.name ()), binding_ (0, 0) + : binding_ (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 (val_bind (true)); } @@ -28,7 +30,7 @@ namespace odb query query_column:: in (const T& v1, const T& v2) const { - query q (name_); + query q (name_, query::clause_part::column); q += "IN ("; q.append (val_bind (v1)); q += ","; @@ -41,7 +43,7 @@ namespace odb query query_column:: 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 (val_bind (v1)); q += ","; @@ -56,7 +58,7 @@ namespace odb query query_column:: 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 (val_bind (v1)); q += ","; @@ -73,7 +75,7 @@ namespace odb query query_column:: 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 (val_bind (v1)); q += ","; @@ -93,7 +95,7 @@ namespace odb query query_column:: 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) -- cgit v1.1