summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-03 17:03:15 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-03 17:03:15 -0400
commit8a865a4d1f7bf7d399a551ae1c3f93e668ccc8aa (patch)
treea5fc83a316ce76951380007dd1495754aab1dcaa /test/sql/test_selectable.py
parentec04620f1fe609881ed2ad4a3d5b2fe313f4efa4 (diff)
downloadsqlalchemy-8a865a4d1f7bf7d399a551ae1c3f93e668ccc8aa.tar.gz
Fixed bug whereby joining a select() of a table "A" with multiple
foreign key paths to a table "B", to that table "B", would fail to produce the "ambiguous join condition" error that would be reported if you join table "A" directly to "B"; it would instead produce a join condition with multiple criteria. [ticket:2738]
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index dc0b040b0..0c5cde9fb 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -781,15 +781,21 @@ class JoinConditionTest(fixtures.TestBase, AssertsExecutionResults):
def test_join_condition(self):
m = MetaData()
t1 = Table('t1', m, Column('id', Integer))
- t2 = Table('t2', m, Column('id', Integer), Column('t1id',
- ForeignKey('t1.id')))
- t3 = Table('t3', m, Column('id', Integer), Column('t1id',
- ForeignKey('t1.id')), Column('t2id',
- ForeignKey('t2.id')))
- t4 = Table('t4', m, Column('id', Integer), Column('t2id',
- ForeignKey('t2.id')))
+ t2 = Table('t2', m, Column('id', Integer),
+ Column('t1id', ForeignKey('t1.id')))
+ t3 = Table('t3', m,
+ Column('id', Integer),
+ Column('t1id', ForeignKey('t1.id')),
+ Column('t2id', ForeignKey('t2.id')))
+ t4 = Table('t4', m, Column('id', Integer),
+ Column('t2id', ForeignKey('t2.id')))
+ t5 = Table('t5', m,
+ Column('t1id1', ForeignKey('t1.id')),
+ Column('t1id2', ForeignKey('t1.id')),
+ )
t1t2 = t1.join(t2)
t2t3 = t2.join(t3)
+
for (left, right, a_subset, expected) in [
(t1, t2, None, t1.c.id == t2.c.t1id),
(t1t2, t3, t2, t1t2.c.t2_id == t3.c.t2id),
@@ -803,12 +809,15 @@ class JoinConditionTest(fixtures.TestBase, AssertsExecutionResults):
assert expected.compare(sql_util.join_condition(left,
right, a_subset=a_subset))
+
# these are ambiguous, or have no joins
for left, right, a_subset in [
(t1t2, t3, None),
(t2t3, t1, None),
(t1, t4, None),
(t1t2, t2t3, None),
+ (t5, t1, None),
+ (t5.select(use_labels=True), t1, None)
]:
assert_raises(
exc.ArgumentError,