mirror of https://github.com/django/django.git
Fixed #25894 -- Fixed evaluation of zero-length slices of QuerySet.values().
This commit is contained in:
parent
423b3afce4
commit
69b69f6d60
|
@ -363,8 +363,6 @@ class SQLCompiler(object):
|
|||
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 '', ()
|
||||
self.subquery = subquery
|
||||
refcounts_before = self.query.alias_refcount.copy()
|
||||
try:
|
||||
|
|
|
@ -37,3 +37,6 @@ Bugfixes
|
|||
|
||||
* Prevented ``QuerySet.delete()`` from crashing on MySQL when querying across
|
||||
relations (:ticket`25882`).
|
||||
|
||||
* Fixed evaluation of zero-length slices of ``QuerySet.values()``
|
||||
(:ticket:`25894`).
|
||||
|
|
|
@ -2429,6 +2429,12 @@ class WeirdQuerysetSlicingTests(BaseQuerysetTest):
|
|||
def test_empty_sliced_subquery_exclude(self):
|
||||
self.assertEqual(Eaten.objects.exclude(food__in=Food.objects.all()[0:0]).count(), 1)
|
||||
|
||||
def test_zero_length_values_slicing(self):
|
||||
n = 42
|
||||
with self.assertNumQueries(0):
|
||||
self.assertQuerysetEqual(Article.objects.values()[n:n], [])
|
||||
self.assertQuerysetEqual(Article.objects.values_list()[n:n], [])
|
||||
|
||||
|
||||
class EscapingTests(TestCase):
|
||||
def test_ticket_7302(self):
|
||||
|
|
Loading…
Reference in New Issue