From 82e874b64b7a56311c10bffa4ffa151d539efe99 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 3 Sep 2012 10:28:26 -0400 Subject: - type expressions invoke in SQL, but are only for the benefit of columns delivered to a result set. therefore these expressions should only be rendered for those columns that are being delivered to the result, thereby preventing the expression from stacking onto itself within nesting scenarios. --- lib/sqlalchemy/sql/compiler.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 2fc14c84c..3778c7683 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -986,15 +986,13 @@ class SQLCompiler(engine.Compiled): within_columns_clause=True): """produce labeled columns present in a select().""" - if column.type._has_column_expression: + if column.type._has_column_expression and \ + populate_result_map: col_expr = column.type.column_expression(column) - if populate_result_map: - add_to_result_map = lambda keyname, name, objects, type_: \ - self._add_to_result_map( - keyname, name, - objects + (column,), type_) - else: - add_to_result_map = None + add_to_result_map = lambda keyname, name, objects, type_: \ + self._add_to_result_map( + keyname, name, + objects + (column,), type_) else: col_expr = column if populate_result_map: -- cgit v1.2.1