diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-07-21 12:36:20 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-07-21 12:36:20 -0400 |
| commit | 30ec982ba697eb320d804164c6bc965ae239abe8 (patch) | |
| tree | 5250f2b709e9771543e208ef759cc5671ee397a3 /test/sql | |
| parent | 547e959157f841f4f6d1e405ceed14755fcbd0bd (diff) | |
| download | sqlalchemy-30ec982ba697eb320d804164c6bc965ae239abe8.tar.gz | |
Allow Grouping to pass along proxy_set of element
Repaired an issue where the "ORDER BY" clause rendering a label name rather
than a complete expression, which is particularly important for SQL Server,
would fail to occur if the expression were enclosed in a parenthesized
grouping in some cases. This case has been added to test support.
Fixes: #5470
Change-Id: Ie0e27c39e5d53be78b32f7810f93d2d0536375e7
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_text.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/sql/test_text.py b/test/sql/test_text.py index 58de41709..1a7ee6f34 100644 --- a/test/sql/test_text.py +++ b/test/sql/test_text.py @@ -15,6 +15,7 @@ from sqlalchemy import MetaData from sqlalchemy import select from sqlalchemy import String from sqlalchemy import Table +from sqlalchemy import testing from sqlalchemy import text from sqlalchemy import union from sqlalchemy import util @@ -710,6 +711,25 @@ class OrderByLabelResolutionTest(fixtures.TestBase, AssertsCompiledSQL): "FROM mytable AS mytable_1 ORDER BY mytable_1.name", ) + @testing.combinations( + ((column("q") + 5).label("a"), "a", ()), + (column("q").op("+")(5).label("a"), "a", ()), + ((column("q") + 5).label("a"), "a DESC", (desc,)), + (column("q").op("+")(5).label("a"), "a DESC", (desc,)), + ) + def test_order_by_expr(self, case, expected, modifiers): + + order_by = case + for mod in modifiers: + order_by = mod(order_by) + + stmt = select([case]).order_by(order_by) + + col_expr = str(case) + self.assert_compile( + stmt, "SELECT %s AS a ORDER BY %s" % (col_expr, expected) + ) + def test_order_by_named_label_from_anon_label(self): s1 = select([table1.c.myid.label(None).label("foo"), table1.c.name]) stmt = s1.order_by("foo") |
