summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/compiler.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 078a8477af..93ba60638a 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -439,6 +439,8 @@ class SQLCompiler:
try:
extra_select, order_by, group_by = self.pre_sql_setup()
for_update_part = None
+ # Is a LIMIT/OFFSET clause needed?
+ with_limit_offset = with_limits and (self.query.high_mark is not None or self.query.low_mark)
combinator = self.query.combinator
features = self.connection.features
if combinator:
@@ -479,7 +481,7 @@ class SQLCompiler:
if self.connection.get_autocommit():
raise TransactionManagementError('select_for_update cannot be used outside of a transaction.')
- if with_limits and not self.connection.features.supports_select_for_update_with_limit:
+ if with_limit_offset and not self.connection.features.supports_select_for_update_with_limit:
raise NotSupportedError(
'LIMIT/OFFSET is not supported with '
'select_for_update on this database backend.'
@@ -531,10 +533,8 @@ class SQLCompiler:
params.extend(o_params)
result.append('ORDER BY %s' % ', '.join(ordering))
- if with_limits:
- limit_offset_sql = self.connection.ops.limit_offset_sql(self.query.low_mark, self.query.high_mark)
- if limit_offset_sql:
- result.append(limit_offset_sql)
+ if with_limit_offset:
+ result.append(self.connection.ops.limit_offset_sql(self.query.low_mark, self.query.high_mark))
if for_update_part and not self.connection.features.for_update_after_from:
result.append(for_update_part)