diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-24 12:28:19 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-24 12:28:19 -0400 |
| commit | 86cebccc4c3cfb687cbbe9703cf732641c55ce44 (patch) | |
| tree | 36ad45dfcfe838562c8c5c1a6ea235459f35dbb0 | |
| parent | bdcaa0f6ca580b54b9c25178441fcbe8f2a4e387 (diff) | |
| download | sqlalchemy-86cebccc4c3cfb687cbbe9703cf732641c55ce44.tar.gz | |
- Turned off the "simple order by" flag on the MSSQL dialect; this
is the flag that per :ticket:`2992` causes an order by or group by
an expression that's also in the columns clause to be copied by
label, even if referenced as the expression object. The behavior
for MSSQL is now the old behavior that copies the whole expression
in by default, as MSSQL can be picky on these particularly in
GROUP BY expressions.
fixes #3338
- Add a test that includes a composed label in a GROUP BY
| -rw-r--r-- | doc/build/changelog/changelog_10.rst | 12 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/base.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_select.py | 9 |
3 files changed, 22 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index 3bcb4d6cf..281092ae1 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -19,6 +19,18 @@ :version: 1.0.0b4 .. change:: + :tags: bug, mssql + :tickets: 3338 + + Turned off the "simple order by" flag on the MSSQL dialect; this + is the flag that per :ticket:`2992` causes an order by or group by + an expression that's also in the columns clause to be copied by + label, even if referenced as the expression object. The behavior + for MSSQL is now the old behavior that copies the whole expression + in by default, as MSSQL can be picky on these particularly in + GROUP BY expressions. + + .. change:: :tags: feature, schema :tickets: 3341 diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index ea0ed58a4..26b794712 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1416,6 +1416,7 @@ class MSDialect(default.DefaultDialect): use_scope_identity = True max_identifier_length = 128 schema_name = "dbo" + supports_simple_order_by_label = False colspecs = { sqltypes.DateTime: _MSDateTime, diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index 68dadd0a9..ecc92b884 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -86,6 +86,15 @@ class OrderByLabelTest(fixtures.TablesTest): [(7, ), (5, ), (3, )] ) + def test_group_by_composed(self): + table = self.tables.some_table + expr = (table.c.x + table.c.y).label('lx') + stmt = select([func.count(1), expr]).group_by(expr).order_by(expr) + self._assert_result( + stmt, + [(1, 3), (1, 5), (1, 7)] + ) + class LimitOffsetTest(fixtures.TablesTest): __backend__ = True |
