mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #28497 -- Restored the ability to use sliced QuerySets with __exact.
Regression in ec50937bcb
.
Thanks Simon Charette for review.
This commit is contained in:
parent
61a6245dc5
commit
1b73ccc4bf
3 changed files with 39 additions and 0 deletions
|
@ -848,6 +848,28 @@ class LookupTests(TestCase):
|
|||
self.assertTrue(Season.objects.filter(nulled_text_field__nulled__exact=None))
|
||||
self.assertTrue(Season.objects.filter(nulled_text_field__nulled=None))
|
||||
|
||||
def test_exact_sliced_queryset_limit_one(self):
|
||||
self.assertCountEqual(
|
||||
Article.objects.filter(author=Author.objects.all()[:1]),
|
||||
[self.a1, self.a2, self.a3, self.a4]
|
||||
)
|
||||
|
||||
def test_exact_sliced_queryset_limit_one_offset(self):
|
||||
self.assertCountEqual(
|
||||
Article.objects.filter(author=Author.objects.all()[1:2]),
|
||||
[self.a5, self.a6, self.a7]
|
||||
)
|
||||
|
||||
def test_exact_sliced_queryset_not_limited_to_one(self):
|
||||
msg = (
|
||||
'The QuerySet value for an exact lookup must be limited to one '
|
||||
'result using slicing.'
|
||||
)
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
list(Article.objects.filter(author=Author.objects.all()[:2]))
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
list(Article.objects.filter(author=Author.objects.all()[1:]))
|
||||
|
||||
def test_custom_field_none_rhs(self):
|
||||
"""
|
||||
__exact=value is transformed to __isnull=True if Field.get_prep_value()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue