diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2017-10-09 18:07:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-09 18:07:03 +0200 |
| commit | 0899d583bdb140910698d00d17f5f1abc8774b07 (patch) | |
| tree | 78bb4ad64476636f4ac5dad34c1c9338b1f99836 /django/db/models/sql | |
| parent | 81d5320db56f28514c346edfec42559f5da4b343 (diff) | |
Fixed #28670 -- Added FETCH/OFFSET support on Oracle.
Thanks Tim Graham for the review.
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 10 |
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) |
