summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBendeguz Csirmaz <csirmazbendeguz@gmail.com>2024-09-11 00:48:56 +0800
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-09-11 12:42:17 +0200
commit0bfaa55708d402432d44882d9a8e4cb85011472c (patch)
treef6d10d2de3b7dd9509bf55c68de4fee61e44d2b4 /tests
parent727587c08955e4e42a5b82bfb75d51517b50c976 (diff)
Fixed #35752 -- Fixed crash when using In() lookup in filters.
Diffstat (limited to 'tests')
-rw-r--r--tests/lookup/tests.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
index 68adbe6496..df96546d04 100644
--- a/tests/lookup/tests.py
+++ b/tests/lookup/tests.py
@@ -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),