summaryrefslogtreecommitdiff
path: root/test/sql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-04-24 17:04:35 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-04-24 17:04:35 -0400
commitf9275198c304ce0603594350b1e60fe753e80673 (patch)
tree91fa1ca298ca38c918865134400694cae346b7c1 /test/sql/test_compiler.py
parent01700759346c82d6a39ee6a6c70581e8417b9c45 (diff)
downloadsqlalchemy-f9275198c304ce0603594350b1e60fe753e80673.tar.gz
- Fixed a regression that was incorrectly fixed in 1.0.0b4
(hence becoming two regressions); reports that SELECT statements would GROUP BY a label name and fail was misconstrued that certain backends such as SQL Server should not be emitting ORDER BY or GROUP BY on a simple label name at all; when in fact, we had forgotten that 0.9 was already emitting ORDER BY on a simple label name for all backends, as described in :ref:`migration_1068`, as 1.0 had rewritten this logic as part of :ticket:`2992`. In 1.0.2, the bug is fixed both that SQL Server, Firebird and others will again emit ORDER BY on a simple label name when passed a :class:`.Label` construct that is expressed in the columns clause, and no backend will emit GROUP BY on a simple label name in this case, as even Postgresql can't reliably do GROUP BY on a simple name in every case. fixes #3338, fixes #3385
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r--test/sql/test_compiler.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index 03646d78d..04e3171a9 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -961,6 +961,19 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
dialect=dialect
)
+ def test_no_group_by_labels(self):
+ lab1 = (table1.c.myid + 12).label('foo')
+ lab2 = func.somefunc(table1.c.name).label('bar')
+ dialect = default.DefaultDialect()
+
+ self.assert_compile(
+ select([lab1, lab2]).group_by(lab1, lab2),
+ "SELECT mytable.myid + :myid_1 AS foo, somefunc(mytable.name) "
+ "AS bar FROM mytable GROUP BY mytable.myid + :myid_1, "
+ "somefunc(mytable.name)",
+ dialect=dialect
+ )
+
def test_conjunctions(self):
a, b, c = text('a'), text('b'), text('c')
x = and_(a, b, c)