diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-31 20:04:04 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-31 20:04:04 -0400 |
commit | 51f1fdf3e40065e349310a6ba9a49306b9648160 (patch) | |
tree | f8950316421ba71113393f6184eedd550e28f218 /lib/sqlalchemy/sql/expression.py | |
parent | 19d04346260e794c7364d7f7ce2415602e6f101c (diff) | |
download | sqlalchemy-51f1fdf3e40065e349310a6ba9a49306b9648160.tar.gz |
- [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]
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 11 |
1 files changed, 7 insertions, 4 deletions
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'] |