summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-04-10 22:33:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-04-10 22:33:33 -0400
commitfcda519452cf5e0cdbde7569ab32459b9f314f7a (patch)
tree4c89b5b4ca328740a83e09b5f2e2200dfc8919e8
parent9f74861d6d2962cb255887c78d5d0f4cb8891cfa (diff)
downloadsqlalchemy-fcda519452cf5e0cdbde7569ab32459b9f314f7a.tar.gz
- 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. fix #3020, re: #1068
-rw-r--r--doc/build/changelog/changelog_09.rst8
-rw-r--r--lib/sqlalchemy/sql/compiler.py2
-rw-r--r--test/sql/test_quote.py9
3 files changed, 18 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst
index 578edd93f..236308325 100644
--- a/doc/build/changelog/changelog_09.rst
+++ b/doc/build/changelog/changelog_09.rst
@@ -15,6 +15,14 @@
: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
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index af40b2537..31193ab17 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 76a789242..6a8abde0b 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()