diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-21 13:12:15 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-21 13:12:15 -0400 |
| commit | c09c21c9f31826e126b97d6318a9df66986af774 (patch) | |
| tree | cd4491e60aa33b8f44bc5279f96e189fe4597f47 /test/sql/test_text.py | |
| parent | 10593e77689cf3c9d6d0de957632d42fd74bf697 (diff) | |
| download | sqlalchemy-c09c21c9f31826e126b97d6318a9df66986af774.tar.gz | |
- Fixed bug in new "label resolution" feature of :ticket:`2992` where
the string label placed in the order_by() or group_by() of a statement
would place higher priority on the name as found
inside the FROM clause instead of a more locally available name
inside the columns clause.
fixes #3335
Diffstat (limited to 'test/sql/test_text.py')
| -rw-r--r-- | test/sql/test_text.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/sql/test_text.py b/test/sql/test_text.py index c2f4d2c15..4483597ac 100644 --- a/test/sql/test_text.py +++ b/test/sql/test_text.py @@ -574,6 +574,20 @@ class OrderByLabelResolutionTest(fixtures.TestBase, AssertsCompiledSQL): "FROM mytable AS mytable_1 ORDER BY mytable_1.name" ) + def test_order_by_outermost_label(self): + # test [ticket:3335], assure that order_by("foo") + # catches the label named "foo" in the columns clause only, + # and not the label named "foo" in the FROM clause + s1 = select([table1.c.myid.label("foo"), table1.c.name]).alias() + stmt = select([s1.c.name, func.bar().label("foo")]).order_by("foo") + + self.assert_compile( + stmt, + "SELECT anon_1.name, bar() AS foo FROM " + "(SELECT mytable.myid AS foo, mytable.name AS name " + "FROM mytable) AS anon_1 ORDER BY foo" + ) + def test_unresolvable_warning_order_by(self): stmt = select([table1.c.myid]).order_by('foobar') self._test_warning( |
