mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Fixed #35167 -- Delegated to super() in JSONField.get_db_prep_save().
Avoids reports of bulk_update() sending Cast expressions to JSONField.get_prep_value(). Co-authored-by: Simon Charette <charette.s@gmail.com>
This commit is contained in:
@@ -40,7 +40,13 @@ from django.db.models.functions import Cast
|
||||
from django.test import SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature
|
||||
from django.test.utils import CaptureQueriesContext
|
||||
|
||||
from .models import CustomJSONDecoder, JSONModel, NullableJSONModel, RelatedJSONModel
|
||||
from .models import (
|
||||
CustomJSONDecoder,
|
||||
CustomSerializationJSONModel,
|
||||
JSONModel,
|
||||
NullableJSONModel,
|
||||
RelatedJSONModel,
|
||||
)
|
||||
|
||||
|
||||
@skipUnlessDBFeature("supports_json_field")
|
||||
@@ -298,6 +304,17 @@ class TestSaveLoad(TestCase):
|
||||
obj.refresh_from_db()
|
||||
self.assertEqual(obj.value, value)
|
||||
|
||||
def test_bulk_update_custom_get_prep_value(self):
|
||||
objs = CustomSerializationJSONModel.objects.bulk_create(
|
||||
[CustomSerializationJSONModel(pk=1, json_field={"version": "1"})]
|
||||
)
|
||||
objs[0].json_field["version"] = "1-alpha"
|
||||
CustomSerializationJSONModel.objects.bulk_update(objs, ["json_field"])
|
||||
self.assertSequenceEqual(
|
||||
CustomSerializationJSONModel.objects.values("json_field"),
|
||||
[{"json_field": '{"version": "1-alpha"}'}],
|
||||
)
|
||||
|
||||
|
||||
@skipUnlessDBFeature("supports_json_field")
|
||||
class TestQuerying(TestCase):
|
||||
|
||||
Reference in New Issue
Block a user