1
0
mirror of https://github.com/django/django.git synced 2025-10-30 00:56:09 +00:00

Refs #36143 -- Tested bulk_batch_size limit for bulk_update and bulk_create.

This commit is contained in:
Sage Abdullah
2025-05-08 09:10:00 +02:00
committed by Sarah Boyce
parent 37f2a77c72
commit 38660a612c
2 changed files with 19 additions and 0 deletions

View File

@@ -293,6 +293,14 @@ class BulkCreateTests(TestCase):
with self.assertNumQueries(ceil(len(objs) / max_batch_size)):
Country.objects.bulk_create(objs, batch_size=max_batch_size + 1)
@skipUnlessDBFeature("has_bulk_insert")
def test_max_batch_size(self):
objs = [Country(name=f"Country {i}") for i in range(1000)]
fields = ["name", "iso_two_letter", "description"]
max_batch_size = connection.ops.bulk_batch_size(fields, objs)
with self.assertNumQueries(ceil(len(objs) / max_batch_size)):
Country.objects.bulk_create(objs)
@skipUnlessDBFeature("has_bulk_insert")
def test_bulk_insert_expressions(self):
Restaurant.objects.bulk_create(