From 5da667e017276f6dc48aa8698c899f6abae0f6ca Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 30 Apr 2014 19:06:26 -0400 Subject: - Fixed bug where the combination of "limit" rendering as "SELECT FIRST n ROWS" using a bound parameter (only firebird has both), combined with column-level subqueries which also feature "limit" as well as "positional" bound parameters (e.g. qmark style) would erroneously assign the subquery-level positions before that of the enclosing SELECT, thus returning parameters which are out of order. Fixes #3038 --- lib/sqlalchemy/sql/compiler.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 31193ab17..080fb43f9 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1481,19 +1481,6 @@ class SQLCompiler(Compiled): 'within_columns_clause': False }) - # the actual list of columns to print in the SELECT column list. - inner_columns = [ - c for c in [ - self._label_select_column(select, - column, - populate_result_map, asfrom, - column_clause_args, - name=name) - for name, column in select._columns_plus_names - ] - if c is not None - ] - text = "SELECT " # we're off to a good start ! if select._hints: @@ -1514,6 +1501,20 @@ class SQLCompiler(Compiled): text += self._generate_prefixes(select, select._prefixes, **kwargs) text += self.get_select_precolumns(select) + + # the actual list of columns to print in the SELECT column list. + inner_columns = [ + c for c in [ + self._label_select_column(select, + column, + populate_result_map, asfrom, + column_clause_args, + name=name) + for name, column in select._columns_plus_names + ] + if c is not None + ] + text += ', '.join(inner_columns) if froms: -- cgit v1.2.1