summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2015-12-18 00:16:43 +0500
committerTim Graham <timograham@gmail.com>2015-12-17 17:07:54 -0500
commit14146f6347e5f8ec6b58b2cd79b68bffae8b8e58 (patch)
tree1134466a4d4da0f268adf67b0901fa06cb36afe0
parentbadeb56f833138fe637607fe3c7e4bfae3048e50 (diff)
[1.9.x] Refs #25894 -- Fixed evaluation of zero-length slices of QuerySet.values() on Oracle.
Backport of ed1bcf05158acf4bf4e0189d477b6c762bd0133e from master
-rw-r--r--django/db/backends/oracle/compiler.py3
-rw-r--r--django/db/models/sql/compiler.py2
-rw-r--r--django/db/models/sql/query.py3
3 files changed, 3 insertions, 5 deletions
diff --git a/django/db/backends/oracle/compiler.py b/django/db/backends/oracle/compiler.py
index 1044a5feb7..7073dc34e8 100644
--- a/django/db/backends/oracle/compiler.py
+++ b/django/db/backends/oracle/compiler.py
@@ -12,9 +12,6 @@ class SQLCompiler(compiler.SQLCompiler):
If 'with_limits' is False, any limit/offset information is not
included in the query.
"""
- if with_limits and self.query.low_mark == self.query.high_mark:
- return '', ()
-
# The `do_offset` flag indicates whether we need to construct
# the SQL needed to use limit/offset with Oracle.
do_offset = with_limits and (self.query.high_mark is not None
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index ed07eaff10..48b00461e9 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -380,8 +380,6 @@ class SQLCompiler(object):
refcounts_before = self.query.alias_refcount.copy()
try:
extra_select, order_by, group_by = self.pre_sql_setup()
- if with_limits and self.query.low_mark == self.query.high_mark:
- return '', ()
distinct_fields = self.get_distinct()
# This must come after 'select', 'ordering', and 'distinct' -- see
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 4f5f7aad68..2b446b9ef3 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1565,6 +1565,9 @@ class Query(object):
else:
self.low_mark = self.low_mark + low
+ if self.low_mark == self.high_mark:
+ self.set_empty()
+
def clear_limits(self):
"""
Clears any existing limits.