mirror of
https://github.com/django/django.git
synced 2025-08-02 18:13:02 +00:00
Fixed #12192 -- Don't execute any DB query when the QS slicing being performed
will result in use of LIMIT 0. Thanks Suor for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14204 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5f5a61e780
commit
08d14925c9
3 changed files with 16 additions and 1 deletions
|
@ -86,8 +86,18 @@ class EmptyQuerySetTests(TestCase):
|
|||
def test_emptyqueryset_values(self):
|
||||
"#14366 -- calling .values() on an EmptyQuerySet and then cloning that should not cause an error"
|
||||
self.assertEqual(list(Number.objects.none().values('num').order_by('num')), [])
|
||||
|
||||
|
||||
def test_values_subquery(self):
|
||||
self.assertQuerysetEqual(
|
||||
Number.objects.filter(pk__in=Number.objects.none().values("pk")), []
|
||||
)
|
||||
|
||||
|
||||
class WeirdQuerySetSlicing(TestCase):
|
||||
def setUp(self):
|
||||
Number.objects.create(num=1)
|
||||
Number.objects.create(num=2)
|
||||
|
||||
def test_empty_resultset_sql(self):
|
||||
# ticket #12192
|
||||
self.assertNumQueries(0, lambda: list(Number.objects.all()[1:1]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue