From: Mike Bayer Date: Fri, 11 Apr 2014 02:33:33 +0000 (-0400) Subject: - Fixed regression introduced in 0.9 where new "ORDER BY " X-Git-Tag: rel_0_9_5~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcda519452cf5e0cdbde7569ab32459b9f314f7a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed regression introduced in 0.9 where new "ORDER BY " feature from :ticket:`1068` would not apply quoting rules to the label name as rendered in the ORDER BY. fix #3020, re: #1068 --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 578edd93f8..2363083257 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,14 @@ .. changelog:: :version: 0.9.5 + .. change:: + :tags: bug, sql + :tickets: 3020, 1068 + + Fixed regression introduced in 0.9 where new "ORDER BY " + 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 diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index af40b25372..31193ab178 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -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, diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index 76a789242d..6a8abde0bb 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -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()