From 09a503e49724b61a8119f0b7855a990a29fc1521 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 22 Jan 2012 14:04:20 -0500 Subject: - [bug] Fixed bug whereby a table-bound Column object named "_" which matched a column labeled as "_" could match inappropriately when targeting in a result set row. [ticket:2377] - requires that we change the tuple format in RowProxy. Makes an improvement to the cases tested against an unpickled RowProxy as well though doesn't solve the problem there entirely. --- lib/sqlalchemy/sql/compiler.py | 4 ++++ lib/sqlalchemy/sql/expression.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 724e7dc2a..c63ae1aea 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -157,6 +157,10 @@ class _CompileLabel(visitors.Visitable): self.element = col self.name = name + @property + def proxy_set(self): + return self.element.proxy_set + @property def type(self): return self.element.type diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 9f2a16195..bff086e4b 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2087,6 +2087,13 @@ class ColumnElement(ClauseElement, _CompareMixin): return bool(self.proxy_set.intersection(othercolumn.proxy_set)) + def _compare_name_for_result(self, other): + """Return True if the given column element compares to this one + when targeting within a result row.""" + + return hasattr(other, 'name') and hasattr(self, 'name') and \ + other.name == self.name + def _make_proxy(self, selectable, name=None): """Create a new :class:`.ColumnElement` representing this :class:`.ColumnElement` as it appears in the select list of a @@ -3919,6 +3926,13 @@ class ColumnClause(_Immutable, ColumnElement): self.type = sqltypes.to_instance(type_) self.is_literal = is_literal + def _compare_name_for_result(self, other): + if self.table is not None and hasattr(other, 'proxy_set'): + return other.proxy_set.intersection(self.proxy_set) + else: + return super(ColumnClause, self).\ + _compare_name_for_result(other) + def _get_table(self): return self.__dict__['table'] def _set_table(self, table): -- cgit v1.2.1