diff options
| author | JaeHyuck Sa <wogur981208@gmail.com> | 2025-12-21 22:45:21 +0900 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-22 14:25:45 -0500 |
| commit | 163d92c1d66e2437a676da4ac8b11291dea3290b (patch) | |
| tree | 24793364cb492f051d3b56a54a415ce027e10e5f | |
| parent | 95394443bff2cd6c5cb47c752422fe1f391bb43d (diff) | |
Fixed #36787 -- Fixed crash in In lookups with mixed expressions and strings.
Signed-off-by: JaeHyuck Sa <wogur981208@gmail.com>
| -rw-r--r-- | django/db/models/lookups.py | 2 | ||||
| -rw-r--r-- | tests/lookup/tests.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py index 769b9c9198..3489fe1e40 100644 --- a/django/db/models/lookups.py +++ b/django/db/models/lookups.py @@ -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 ] diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py index 5b9dd8e5ec..31f247964c 100644 --- a/tests/lookup/tests.py +++ b/tests/lookup/tests.py @@ -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), |
