summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2024-12-23 05:00:04 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-02-06 17:00:31 +0100
commitd99985bbc121749c5a6bb9eb9a4a9099b6a002eb (patch)
tree40e36ec7c6c73d13015354e1b9c28fe71d757168 /tests/model_fields
parentb96e4c04b666b1044555d7a32f64e83cbad57b03 (diff)
[5.2.x] Fixed #36025 -- Fixed re-aliasing of iterable (in/range) lookups rhs.
In order for Expression.relabeled_clone to work appropriately its get_source_expressions method must return all resolvable which wasn't the case for Lookup when its right-hand-side is "direct" (not a compilable). While refs #22288 added support for non-literals iterable right-hand-side lookups it predated the subclassing of Lookup(Expression) refs #27021 which could have been an opportunity to ensure right-hand-sides are always resolvable (ValueList and ExpressionList). Addressing all edge case with non-resolvable right-hand-sides would require a significant refactor and deprecation of some parts of the Lookup interface so this patch only focuses on FieldGetDbPrepValueIterableMixin (In and Range lookups) by making sure that a right-hand-side containing resolvables are dealt with appropriately during the resolving phase. Thanks Aashay Amballi for the report. Backport of 089deb82b9ac2d002af36fd36f288368cdac4b53 from main.
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/test_jsonfield.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
index 09f95ce69f..5a9cf9ad7a 100644
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -13,6 +13,7 @@ from django.db import (
OperationalError,
connection,
models,
+ transaction,
)
from django.db.models import (
Count,
@@ -974,7 +975,7 @@ class TestQuerying(TestCase):
("value__i__in", [False, "foo"], [self.objs[4]]),
]
for lookup, value, expected in tests:
- with self.subTest(lookup=lookup, value=value):
+ with self.subTest(lookup=lookup, value=value), transaction.atomic():
self.assertCountEqual(
NullableJSONModel.objects.filter(**{lookup: value}),
expected,