diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-04 21:38:56 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-04 21:38:56 -0400 |
commit | 26ec0507be72d2e1a5abde8b7307012864a88a6b (patch) | |
tree | b83e68a0ee000059ff176d29f68706fb0a6da830 /test/sql/test_selectable.py | |
parent | ada19275299f0105f4aaed5bbe0d373ea33feea6 (diff) | |
parent | 69e9574fefd5fbb4673c99ad476a00b03fe22318 (diff) | |
download | sqlalchemy-26ec0507be72d2e1a5abde8b7307012864a88a6b.tar.gz |
Merge branch 'ticket_2587'
Conflicts:
test/profiles.txt
test/sql/test_selectable.py
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r-- | test/sql/test_selectable.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 0c5cde9fb..2ac04dce3 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -776,12 +776,13 @@ class AnonLabelTest(fixtures.TestBase): c1 = literal_column('x') eq_(str(select([c1.label('y')])), "SELECT x AS y") -class JoinConditionTest(fixtures.TestBase, AssertsExecutionResults): +class JoinConditionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): def test_join_condition(self): m = MetaData() t1 = Table('t1', m, Column('id', Integer)) - t2 = Table('t2', m, Column('id', Integer), + t2 = Table('t2', m, + Column('id', Integer), Column('t1id', ForeignKey('t1.id'))) t3 = Table('t3', m, Column('id', Integer), @@ -793,6 +794,7 @@ class JoinConditionTest(fixtures.TestBase, AssertsExecutionResults): Column('t1id1', ForeignKey('t1.id')), Column('t1id2', ForeignKey('t1.id')), ) + t1t2 = t1.join(t2) t2t3 = t2.join(t3) @@ -841,21 +843,23 @@ class JoinConditionTest(fixtures.TestBase, AssertsExecutionResults): left.join(right).onclause ) + # these are right-nested joins + j = t1t2.join(t2t3) + assert j.onclause.compare(t2.c.id == t3.c.t2id) + self.assert_compile(j, + "t1 JOIN t2 ON t1.id = t2.t1id JOIN " + "(t2 JOIN t3 ON t2.id = t3.t2id) ON t2.id = t3.t2id") + + st2t3 = t2t3.select(use_labels=True) + j = t1t2.join(st2t3) + assert j.onclause.compare(t2.c.id == st2t3.c.t3_t2id) + self.assert_compile(j, + "t1 JOIN t2 ON t1.id = t2.t1id JOIN " + "(SELECT t2.id AS t2_id, t2.t1id AS t2_t1id, " + "t3.id AS t3_id, t3.t1id AS t3_t1id, t3.t2id AS t3_t2id " + "FROM t2 JOIN t3 ON t2.id = t3.t2id) ON t2.id = t3_t2id") - # TODO: this raises due to right side being "grouped", and no - # longer has FKs. Did we want to make FromGrouping friendlier - # ? - - assert_raises_message(exc.ArgumentError, - "Perhaps you meant to convert the right " - "side to a subquery using alias\(\)\?", - t1t2.join, t2t3) - assert_raises_message(exc.ArgumentError, - "Perhaps you meant to convert the right " - "side to a subquery using alias\(\)\?", - t1t2.join, t2t3.select(use_labels=True)) - def test_join_cond_no_such_unrelated_table(self): m = MetaData() |