Skip to content

Commit

Permalink
import changes from Django 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
michiya committed Mar 9, 2018
1 parent a47e64d commit a5be65a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sql_server/pyodbc/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
# to exclude extraneous selects.
sub_selects = []
sub_params = []
for select, _, alias in self.select:
for index, (select, _, alias) in enumerate(self.select, start=1):
if not alias and with_col_aliases:
alias = 'col%d' % index
if alias:
sub_selects.append("%s.%s" % (
self.connection.ops.quote_name('subquery'),
Expand All @@ -269,7 +271,7 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
return 'SELECT %s FROM (%s) subquery' % (
', '.join(sub_selects),
' '.join(result),
), sub_params + params
), tuple(sub_params + params)

return ' '.join(result), tuple(params)
finally:
Expand Down

0 comments on commit a5be65a

Please sign in to comment.