]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed regression introduced in 0.9 where new "ORDER BY <labelname>"
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Apr 2014 02:33:33 +0000 (22:33 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Apr 2014 02:33:33 +0000 (22:33 -0400)
feature from :ticket:`1068` would not apply quoting rules to the
label name as rendered in the ORDER BY.
fix #3020, re: #1068

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/sql/compiler.py
test/sql/test_quote.py

index 578edd93f87888f686334bbadef3902c976b9874..236308325798ecfb20e5dd67d14c036c18c93c5d 100644 (file)
 .. changelog::
     :version: 0.9.5
 
+    .. change::
+        :tags: bug, sql
+        :tickets: 3020, 1068
+
+        Fixed regression introduced in 0.9 where new "ORDER BY <labelname>"
+        feature from :ticket:`1068` would not apply quoting rules to the
+        label name as rendered in the ORDER BY.
+
     .. change::
         :tags: feature, orm
         :tickets: 3017
index af40b25372bb04ede0db661be06c2f840a151093..31193ab1789e2e27d1d69dc3f6c21bd1db89d1c4 100644 (file)
@@ -521,7 +521,7 @@ class SQLCompiler(Compiled):
                         OPERATORS[operators.as_] + \
                         self.preparer.format_label(label, labelname)
         elif render_label_only:
-            return labelname
+            return self.preparer.format_label(label, labelname)
         else:
             return label.element._compiler_dispatch(self,
                                     within_columns_clause=False,
index 76a789242d0da251fc688b6efa3d6a6ac9bd17a5..6a8abde0bb9bd228cb3c7a6734024c8a0e4b3fb0 100644 (file)
@@ -443,6 +443,15 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
                 '"Anon".Col1 = :Col1_1'
         )
 
+    def test_simple_order_by_label(self):
+        m = MetaData()
+        t1 = Table('t1', m, Column('col1', Integer))
+        cl = t1.c.col1.label('ShouldQuote')
+        self.assert_compile(
+            select([cl]).order_by(cl),
+            'SELECT t1.col1 AS "ShouldQuote" FROM t1 ORDER BY "ShouldQuote"'
+        )
+
     def test_join(self):
         # Lower case names, should not quote
         metadata = MetaData()