mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Thanks to Adam Johnson, Carlton Gibson, Mariusz Felisiak, and Raphael Michel for mentoring this Google Summer of Code 2019 project and everyone else who helped with the patch. Special thanks to Mads Jensen, Nick Pope, and Simon Charette for extensive reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
@@ -3,11 +3,11 @@ import datetime
|
||||
from django.core.exceptions import FieldDoesNotExist
|
||||
from django.db.models import F
|
||||
from django.db.models.functions import Lower
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
|
||||
from .models import (
|
||||
Article, CustomDbColumn, CustomPk, Detail, Individual, Member, Note,
|
||||
Number, Order, Paragraph, SpecialCategory, Tag, Valid,
|
||||
Article, CustomDbColumn, CustomPk, Detail, Individual, JSONFieldNullable,
|
||||
Member, Note, Number, Order, Paragraph, SpecialCategory, Tag, Valid,
|
||||
)
|
||||
|
||||
|
||||
@@ -228,3 +228,14 @@ class BulkUpdateTests(TestCase):
|
||||
article.created = point_in_time
|
||||
Article.objects.bulk_update(articles, ['created'])
|
||||
self.assertCountEqual(Article.objects.filter(created=point_in_time), articles)
|
||||
|
||||
@skipUnlessDBFeature('supports_json_field')
|
||||
def test_json_field(self):
|
||||
JSONFieldNullable.objects.bulk_create([
|
||||
JSONFieldNullable(json_field={'a': i}) for i in range(10)
|
||||
])
|
||||
objs = JSONFieldNullable.objects.all()
|
||||
for obj in objs:
|
||||
obj.json_field = {'c': obj.json_field['a'] + 1}
|
||||
JSONFieldNullable.objects.bulk_update(objs, ['json_field'])
|
||||
self.assertCountEqual(JSONFieldNullable.objects.filter(json_field__has_key='c'), objs)
|
||||
|
||||
Reference in New Issue
Block a user