From 1321db6473a45517bbb86203e9cbdd4c02fa8ac0 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 23 Mar 2010 20:41:40 -0400 Subject: - Fixed bug introduced in 0.6beta2 where column labels would render inside of column expressions already assigned a label. [ticket:1747] --- lib/sqlalchemy/sql/compiler.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 4e9175ae8..75b3f79f0 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -305,11 +305,13 @@ class SQLCompiler(engine.Compiled): def visit_grouping(self, grouping, asfrom=False, **kwargs): return "(" + self.process(grouping.element, **kwargs) + ")" - def visit_label(self, label, result_map=None, within_columns_clause=False, **kw): + def visit_label(self, label, result_map=None, + within_label_clause=False, + within_columns_clause=False, **kw): # only render labels within the columns clause # or ORDER BY clause of a select. dialect-specific compilers # can modify this behavior. - if within_columns_clause: + if within_columns_clause and not within_label_clause: labelname = isinstance(label.name, sql._generated_label) and \ self._truncated_identifier("colident", label.name) or label.name @@ -318,13 +320,14 @@ class SQLCompiler(engine.Compiled): (label.name, (label, label.element, labelname), label.element.type) return self.process(label.element, - within_columns_clause=within_columns_clause, + within_columns_clause=True, + within_label_clause=True, **kw) + \ OPERATORS[operators.as_] + \ self.preparer.format_label(label, labelname) else: return self.process(label.element, - within_columns_clause=within_columns_clause, + within_columns_clause=False, **kw) def visit_column(self, column, result_map=None, **kwargs): -- cgit v1.2.1