Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mssql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
params.extend(o_params)
result.append('ORDER BY %s' % ', '.join(ordering))

# For subqueres with an ORDER BY clause, SQL Server also
# requires a TOP or OFFSET clause which is not generated for
# Django 2.x. See https://github.com/microsoft/mssql-django/issues/12
if django.VERSION < (3, 0, 0) and not (do_offset or do_limit):
result.append("OFFSET 0 ROWS")

# SQL Server requires the backend-specific emulation (2008 or earlier)
# or an offset clause (2012 or newer) for offsetting
if do_offset:
Expand Down