From 9154e1eff1da41c41b31e2a24a6128ff457c7716 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 5 Mar 2007 23:08:52 +0000 Subject: - added concept of 'require_embedded' to corresponding_column. requires that the target column be present in a sub-element of the target selectable. - embedded logic above more appropriate for ClauseAdapter functionality since its trying to "pull up" clauses that represent columns within a larger union up to the level of the union itself. - the "direction" test against the "foreign_keys" collection apparently works for an exact "column 'x' is present in the collection", no proxy relationships needed. fixes the case of relating a selectable/alias to one of its underlying tables, probably fixes other scenarios --- lib/sqlalchemy/sql_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/sql_util.py') diff --git a/lib/sqlalchemy/sql_util.py b/lib/sqlalchemy/sql_util.py index 3eb4b6d06..70fc85702 100644 --- a/lib/sqlalchemy/sql_util.py +++ b/lib/sqlalchemy/sql_util.py @@ -178,7 +178,7 @@ class Aliasizer(AbstractClauseProcessor): class ClauseAdapter(AbstractClauseProcessor): """Given a clause (like as in a WHERE criterion), locate columns - which *correspond* to a given selectable, and changes those + which are embedded within a given selectable, and changes those columns to be that of the selectable. E.g.:: @@ -219,10 +219,10 @@ class ClauseAdapter(AbstractClauseProcessor): if self.exclude is not None: if col in self.exclude: return None - newcol = self.selectable.corresponding_column(col, raiseerr=False, keys_ok=False) + newcol = self.selectable.corresponding_column(col, raiseerr=False, require_embedded=True, keys_ok=False) if newcol is None and self.equivalents is not None and col in self.equivalents: for equiv in self.equivalents[col]: - newcol = self.selectable.corresponding_column(equiv, raiseerr=False, keys_ok=False) + newcol = self.selectable.corresponding_column(equiv, raiseerr=False, require_embedded=True, keys_ok=False) if newcol: return newcol return newcol -- cgit v1.2.1