Skip to content

Commit 69567f6

Browse files
committed
import changes from Django 1.11.4
1 parent 25901e7 commit 69567f6

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

sql_server/pyodbc/compiler.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
7878
refcounts_before = self.query.alias_refcount.copy()
7979
try:
8080
extra_select, order_by, group_by = self.pre_sql_setup()
81+
for_update_part = None
82+
combinator = self.query.combinator
83+
features = self.connection.features
8184

8285
# The do_offset flag indicates whether we need to construct
8386
# the SQL needed to use limit/offset w/SQL Server.
@@ -89,23 +92,17 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
8992
supports_offset_clause = self.connection.sql_server_version >= 2012
9093
do_offset_emulation = do_offset and not supports_offset_clause
9194

92-
distinct_fields = self.get_distinct()
93-
94-
# This must come after 'select', 'ordering', and 'distinct' -- see
95-
# docstring of get_from_clause() for details.
96-
from_, f_params = self.get_from_clause()
97-
98-
for_update_part = None
99-
where, w_params = self.compile(self.where) if self.where is not None else ("", [])
100-
having, h_params = self.compile(self.having) if self.having is not None else ("", [])
101-
102-
combinator = self.query.combinator
103-
features = self.connection.features
10495
if combinator:
10596
if not getattr(features, 'supports_select_{}'.format(combinator)):
10697
raise DatabaseError('{} not supported on this database backend.'.format(combinator))
10798
result, params = self.get_combinator_sql(combinator, self.query.combinator_all)
10899
else:
100+
distinct_fields = self.get_distinct()
101+
# This must come after 'select', 'ordering', and 'distinct' -- see
102+
# docstring of get_from_clause() for details.
103+
from_, f_params = self.get_from_clause()
104+
where, w_params = self.compile(self.where) if self.where is not None else ("", [])
105+
having, h_params = self.compile(self.having) if self.having is not None else ("", [])
109106
params = []
110107
result = ['SELECT']
111108

0 commit comments

Comments
 (0)