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

[1.4.x] Fixed #17788 -- Added batch_size argument to qs.bulk_create()

The qs.bulk_create() method did not work with large batches together
with SQLite3. This commit adds a way to split the bulk into smaller
batches. The default batch size is unlimited except for SQLite3 where
the batch size is limited to 999 SQL parameters per batch.

Thanks to everybody who participated in the discussions at Trac.

Backpatch of 29132ebdef from master (with
documentation changes removed).
This commit is contained in:
Anssi Kääriäinen
2012-04-29 04:22:05 +03:00
parent f0c469c7be
commit 2326860851
6 changed files with 100 additions and 25 deletions

View File

@@ -1807,8 +1807,7 @@ class ConditionalTests(BaseQuerysetTest):
# Test that the "in" lookup works with lists of 1000 items or more.
Number.objects.all().delete()
numbers = range(2500)
for num in numbers:
_ = Number.objects.create(num=num)
Number.objects.bulk_create(Number(num=num) for num in numbers)
self.assertEqual(
Number.objects.filter(num__in=numbers[:1000]).count(),
1000