summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-12-03 17:28:36 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-12-03 17:28:36 +0000
commit0410eae36b36dc8ea7e747c4b81c7ec9de5f2da4 (patch)
tree86a53b2b2c33a3348d6aca9c7bc825315816748f /test/sql
parent851a14aa1a0e7a734a6f810f0e6e5c39d8e63b1b (diff)
downloadsqlalchemy-0410eae36b36dc8ea7e747c4b81c7ec9de5f2da4.tar.gz
- 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.
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/generative.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/sql/generative.py b/test/sql/generative.py
index f6b849e8a..4edf334f6 100644
--- a/test/sql/generative.py
+++ b/test/sql/generative.py
@@ -458,6 +458,32 @@ class ClauseAdapterTest(TestBase, AssertsCompiledSQL):
assert str(e) == "a_1.id = a.xxx_id"
+ def test_recursive_equivalents(self):
+ m = MetaData()
+ a = Table('a', m, Column('x', Integer), Column('y', Integer))
+ b = Table('b', m, Column('x', Integer), Column('y', Integer))
+ c = Table('c', m, Column('x', Integer), Column('y', Integer))
+
+ # force a recursion overflow, by linking a.c.x<->c.c.x, and
+ # asking for a nonexistent col. corresponding_column should prevent
+ # endless depth.
+ adapt = sql_util.ClauseAdapter( b, equivalents= {a.c.x: set([ c.c.x]), c.c.x:set([a.c.x])})
+ assert adapt._corresponding_column(a.c.x, False) is None
+
+ def test_multilevel_equivalents(self):
+ m = MetaData()
+ a = Table('a', m, Column('x', Integer), Column('y', Integer))
+ b = Table('b', m, Column('x', Integer), Column('y', Integer))
+ c = Table('c', m, Column('x', Integer), Column('y', Integer))
+
+ alias = select([a]).select_from(a.join(b, a.c.x==b.c.x)).alias()
+
+ # two levels of indirection from c.x->b.x->a.x, requires recursive
+ # corresponding_column call
+ adapt = sql_util.ClauseAdapter(alias, equivalents= {b.c.x: set([ a.c.x]), c.c.x:set([b.c.x])})
+ assert adapt._corresponding_column(a.c.x, False) is alias.c.x
+ assert adapt._corresponding_column(c.c.x, False) is alias.c.x
+
def test_join_to_alias(self):
metadata = MetaData()
a = Table('a', metadata,