summaryrefslogtreecommitdiff
path: root/odb/relational/common.cxx
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
commita26f4251e67ccaaaa848982946c8867443092ebe (patch)
treee45089b04feebc45e0cb9b0f6f07cfa941702c78 /odb/relational/common.cxx
parent40d61256a8455ab4a89617a93d3b548457fe37c0 (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/relational/common.cxx')
-rw-r--r--odb/relational/common.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/odb/relational/common.cxx b/odb/relational/common.cxx
index 6032548..2a4a461 100644
--- a/odb/relational/common.cxx
+++ b/odb/relational/common.cxx
@@ -29,7 +29,7 @@ namespace relational
: ptr_ (true), decl_ (false)
{
scope_ = "access::object_traits< " + c.fq_name () + " >::query_columns";
- table_ = table_qname (c);
+ table_ = default_table_ = table_qname (c);
}
void query_columns::
@@ -153,15 +153,20 @@ namespace relational
}
else
{
- // Use the default table alias unless we are generating members
+ // Leave the default table name unless we are generating members
// for a referenced object.
//
string column;
if (!ptr_)
- column = table_;
- else
- column = "_";
+ {
+ // If this is a self-reference, use the special '_' alias.
+ //
+ if (table_ != default_table_)
+ column = table_;
+ else
+ column = "_";
+ }
column += '.';
column += quote_id (col_name);