Fixed #36787 -- Fixed crash in In lookups with mixed expressions and strings.

Signed-off-by: JaeHyuck Sa <wogur981208@gmail.com>
This commit is contained in:
JaeHyuck Sa 2025-12-21 22:45:21 +09:00 committed by Jacob Walls
parent 95394443bf
commit 163d92c1d6
2 changed files with 9 additions and 1 deletions

View file

@ -295,7 +295,7 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
(
value
if hasattr(value, "resolve_expression")
else Value(value, self.lhs.output_field)
else Value(value, getattr(self.lhs, "output_field", None))
)
for value in self.rhs
]

View file

@ -1855,6 +1855,14 @@ class LookupQueryingTests(TestCase):
Season.objects.filter(In(F("year"), years)).order_by("pk"), seasons
)
def test_in_lookup_in_filter_text_field(self):
self.assertSequenceEqual(
Season.objects.filter(
In(F("nulled_text_field"), [F("nulled_text_field"), "special_value"])
),
[self.s2],
)
def test_filter_lookup_lhs(self):
qs = Season.objects.annotate(before_20=LessThan(F("year"), 2000)).filter(
before_20=LessThan(F("year"), 1900),