mirror of
https://github.com/django/django.git
synced 2025-10-30 00:56:09 +00:00
Fixed #35752 -- Fixed crash when using In() lookup in filters.
This commit is contained in:
committed by
Sarah Boyce
parent
727587c089
commit
0bfaa55708
@@ -24,6 +24,7 @@ from django.db.models.lookups import (
|
||||
Exact,
|
||||
GreaterThan,
|
||||
GreaterThanOrEqual,
|
||||
In,
|
||||
IsNull,
|
||||
LessThan,
|
||||
LessThanOrEqual,
|
||||
@@ -1511,6 +1512,25 @@ class LookupQueryingTests(TestCase):
|
||||
[self.s1, self.s3],
|
||||
)
|
||||
|
||||
def test_in_lookup_in_filter(self):
|
||||
test_cases = [
|
||||
((), ()),
|
||||
((1942,), (self.s1,)),
|
||||
((1842,), (self.s2,)),
|
||||
((2042,), (self.s3,)),
|
||||
((1942, 1842), (self.s1, self.s2)),
|
||||
((1942, 2042), (self.s1, self.s3)),
|
||||
((1842, 2042), (self.s2, self.s3)),
|
||||
((1942, 1942, 1942), (self.s1,)),
|
||||
((1942, 2042, 1842), (self.s1, self.s2, self.s3)),
|
||||
]
|
||||
|
||||
for years, seasons in test_cases:
|
||||
with self.subTest(years=years, seasons=seasons):
|
||||
self.assertSequenceEqual(
|
||||
Season.objects.filter(In(F("year"), years)).order_by("pk"), seasons
|
||||
)
|
||||
|
||||
def test_filter_lookup_lhs(self):
|
||||
qs = Season.objects.annotate(before_20=LessThan(F("year"), 2000)).filter(
|
||||
before_20=LessThan(F("year"), 1900),
|
||||
|
||||
Reference in New Issue
Block a user