diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-06-21 14:55:04 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-06-21 14:55:04 -0400 |
| commit | 81eefb2f13a9c854e1dcd924550d0c36553e930a (patch) | |
| tree | f9bd842aac2c435a4e6769bb5d9ec0381bbad4fc /test/sql/test_selectable.py | |
| parent | aa43145f37d693969d34730835f834679e7a7ab4 (diff) | |
| download | sqlalchemy-81eefb2f13a9c854e1dcd924550d0c36553e930a.tar.gz | |
- [bug] Fixed regression introduced in 0.7.6
whereby the FROM list of a SELECT statement
could be incorrect in certain "clone+replace"
scenarios. [ticket:2518]
Diffstat (limited to 'test/sql/test_selectable.py')
| -rw-r--r-- | test/sql/test_selectable.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index ff569288e..f41360359 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -154,6 +154,33 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled cloned.append_column(func.foo()) eq_(cloned.c.keys(), ['a', 'b', 'foo()']) + def test_append_column_after_replace_selectable(self): + basesel = select([literal_column('1').label('a')]) + tojoin = select([ + literal_column('1').label('a'), + literal_column('2').label('b') + ]) + basefrom = basesel.alias('basefrom') + joinfrom = tojoin.alias('joinfrom') + sel = select([basefrom.c.a]) + replaced = sel.replace_selectable( + basefrom, + basefrom.join(joinfrom, basefrom.c.a == joinfrom.c.a) + ) + self.assert_compile( + replaced, + "SELECT basefrom.a FROM (SELECT 1 AS a) AS basefrom " + "JOIN (SELECT 1 AS a, 2 AS b) AS joinfrom " + "ON basefrom.a = joinfrom.a" + ) + replaced.append_column(joinfrom.c.b) + self.assert_compile( + replaced, + "SELECT basefrom.a, joinfrom.b FROM (SELECT 1 AS a) AS basefrom " + "JOIN (SELECT 1 AS a, 2 AS b) AS joinfrom " + "ON basefrom.a = joinfrom.a" + ) + def test_against_cloned_non_table(self): # test that corresponding column digs across # clone boundaries with anonymous labeled elements |
