From 51f1fdf3e40065e349310a6ba9a49306b9648160 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 31 Aug 2012 20:04:04 -0400 Subject: - [bug] Fixed a regression since 0.6 regarding result-row targeting. It should be possible to use a select() statement with string based columns in it, that is select(['id', 'name']).select_from('mytable'), and have this statement be targetable by Column objects with those names; this is the mechanism by which query(MyClass).from_statement(some_statement) works. At some point the specific case of using select(['id']), which is equivalent to select([literal_column('id')]), stopped working here, so this has been re-instated and of course tested. [ticket:2558] --- lib/sqlalchemy/sql/expression.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/sql/expression.py') diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 2583e6510..4edbeafe2 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -4315,12 +4315,15 @@ class ColumnClause(Immutable, ColumnElement): self.is_literal = is_literal def _compare_name_for_result(self, other): - # TODO: this still isn't 100% correct - if self.table is not None and hasattr(other, 'proxy_set'): - return self.proxy_set.intersection(other.proxy_set) - else: + if self.is_literal or \ + self.table is None or \ + not hasattr(other, 'proxy_set') or ( + isinstance(other, ColumnClause) and other.is_literal + ): return super(ColumnClause, self).\ _compare_name_for_result(other) + else: + return other.proxy_set.intersection(self.proxy_set) def _get_table(self): return self.__dict__['table'] -- cgit v1.2.1