diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-28 11:50:09 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-28 11:50:09 -0400 |
| commit | d61919118072f4c31ba2ee0bd8c4ac22a92e92f4 (patch) | |
| tree | 1dd12ef15aa76f25d048377c518ff0c7f03a7fe7 /test | |
| parent | 63d2a486bf84f798387bd45db558610b247e0aa5 (diff) | |
| download | sqlalchemy-d61919118072f4c31ba2ee0bd8c4ac22a92e92f4.tar.gz | |
- Added support for rendering "FULL OUTER JOIN" to both Core and ORM.
Pull request courtesy Stefan Urbanek. fixes #1957
Diffstat (limited to 'test')
| -rw-r--r-- | test/dialect/mysql/test_compiler.py | 27 | ||||
| -rw-r--r-- | test/orm/test_joins.py | 9 | ||||
| -rw-r--r-- | test/sql/test_compiler.py | 20 |
3 files changed, 56 insertions, 0 deletions
diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index 0571ce526..8a7893445 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -576,3 +576,30 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): 'PRIMARY KEY (id, other_id)' ')PARTITION BY HASH(other_id) PARTITIONS 2' ) + + def test_inner_join(self): + t1 = table('t1', column('x')) + t2 = table('t2', column('y')) + + self.assert_compile( + t1.join(t2, t1.c.x == t2.c.y), + "t1 INNER JOIN t2 ON t1.x = t2.y" + ) + + def test_outer_join(self): + t1 = table('t1', column('x')) + t2 = table('t2', column('y')) + + self.assert_compile( + t1.outerjoin(t2, t1.c.x == t2.c.y), + "t1 LEFT OUTER JOIN t2 ON t1.x = t2.y" + ) + + def test_full_outer_join(self): + t1 = table('t1', column('x')) + t2 = table('t2', column('y')) + + self.assert_compile( + t1.outerjoin(t2, t1.c.x == t2.c.y, full=True), + "t1 FULL OUTER JOIN t2 ON t1.x = t2.y" + )
\ No newline at end of file diff --git a/test/orm/test_joins.py b/test/orm/test_joins.py index 540056dae..e7e943e8d 100644 --- a/test/orm/test_joins.py +++ b/test/orm/test_joins.py @@ -455,6 +455,15 @@ class JoinTest(QueryTest, AssertsCompiledSQL): "FROM users LEFT OUTER JOIN orders ON users.id = orders.user_id" ) + def test_full_flag(self): + User = self.classes.User + + self.assert_compile( + create_session().query(User).outerjoin('orders', full=True), + "SELECT users.id AS users_id, users.name AS users_name " + "FROM users FULL OUTER JOIN orders ON users.id = orders.user_id" + ) + def test_multi_tuple_form(self): """test the 'tuple' form of join, now superseded diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 66612eb33..dae178d31 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1553,6 +1553,26 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): "mytable.myid = :myid_1 OR myothertable.othername != :othername_1 " "OR EXISTS (select yay from foo where boo = lar)", ) + def test_full_outer_join(self): + for spec in [ + join(table1, table2, table1.c.myid == table2.c.otherid, full=True), + outerjoin( + table1, table2, + table1.c.myid == table2.c.otherid, full=True), + table1.join( + table2, + table1.c.myid == table2.c.otherid, full=True), + table1.outerjoin( + table2, + table1.c.myid == table2.c.otherid, full=True), + ]: + stmt = select([table1]).select_from(spec) + self.assert_compile( + stmt, + "SELECT mytable.myid, mytable.name, mytable.description FROM " + "mytable FULL OUTER JOIN myothertable " + "ON mytable.myid = myothertable.otherid") + def test_compound_selects(self): assert_raises_message( exc.ArgumentError, |
