From 0410eae36b36dc8ea7e747c4b81c7ec9de5f2da4 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 3 Dec 2008 17:28:36 +0000 Subject: - Two fixes to help prevent out-of-band columns from being rendered in polymorphic_union inheritance scenarios (which then causes extra tables to be rendered in the FROM clause causing cartesian products): - improvements to "column adaption" for a->b->c inheritance situations to better locate columns that are related to one another via multiple levels of indirection, rather than rendering the non-adapted column. - the "polymorphic discriminator" column is only rendered for the actual mapper being queried against. The column won't be "pulled in" from a subclass or superclass mapper since it's not needed. --- lib/sqlalchemy/sql/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index d5f2417c2..1bd4dd857 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -439,12 +439,12 @@ class ClauseAdapter(visitors.ReplacingCloningVisitor): self.exclude = exclude self.equivalents = equivalents or {} - def _corresponding_column(self, col, require_embedded): + def _corresponding_column(self, col, require_embedded, _seen=util.EMPTY_SET): newcol = self.selectable.corresponding_column(col, require_embedded=require_embedded) - if not newcol and col in self.equivalents: + if not newcol and col in self.equivalents and col not in _seen: for equiv in self.equivalents[col]: - newcol = self.selectable.corresponding_column(equiv, require_embedded=require_embedded) + newcol = self._corresponding_column(equiv, require_embedded=require_embedded, _seen=_seen.union([col])) if newcol: return newcol return newcol -- cgit v1.2.1