|
@@ -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()
|