summaryrefslogtreecommitdiff
path: root/tests/bulk_create
diff options
context:
space:
mode:
authorDavid Barragán Merino <david.barragan@kaleidos.net>2016-10-25 16:51:45 +0200
committerTim Graham <timograham@gmail.com>2016-10-25 19:21:08 -0400
commitb3bd3aa07c026239dd39d1a37498dfd0a2f09caf (patch)
tree7556859c8f3c50efa4cfe404a5a5804709f4e40c /tests/bulk_create
parenta9d1d9528496bc5bed7c2d615a232f4ebc192676 (diff)
downloaddjango-b3bd3aa07c026239dd39d1a37498dfd0a2f09caf.tar.gz
Fixed #27385 -- Fixed QuerySet.bulk_create() on PostgreSQL when the number of objects is a multiple plus one of batch_size.
Diffstat (limited to 'tests/bulk_create')
-rw-r--r--tests/bulk_create/tests.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py
index e6d85cb815..3378f0010a 100644
--- a/tests/bulk_create/tests.py
+++ b/tests/bulk_create/tests.py
@@ -171,11 +171,18 @@ class BulkCreateTests(TestCase):
def test_explicit_batch_size(self):
objs = [TwoFields(f1=i, f2=i) for i in range(0, 4)]
- TwoFields.objects.bulk_create(objs, 2)
- self.assertEqual(TwoFields.objects.count(), len(objs))
+ num_objs = len(objs)
+ TwoFields.objects.bulk_create(objs, batch_size=1)
+ self.assertEqual(TwoFields.objects.count(), num_objs)
TwoFields.objects.all().delete()
- TwoFields.objects.bulk_create(objs, len(objs))
- self.assertEqual(TwoFields.objects.count(), len(objs))
+ TwoFields.objects.bulk_create(objs, batch_size=2)
+ self.assertEqual(TwoFields.objects.count(), num_objs)
+ TwoFields.objects.all().delete()
+ TwoFields.objects.bulk_create(objs, batch_size=3)
+ self.assertEqual(TwoFields.objects.count(), num_objs)
+ TwoFields.objects.all().delete()
+ TwoFields.objects.bulk_create(objs, batch_size=num_objs)
+ self.assertEqual(TwoFields.objects.count(), num_objs)
def test_empty_model(self):
NoFields.objects.bulk_create([NoFields() for i in range(2)])