Fixed #31003 -- Doc'd and tested return value of QuerySet.bulk_create().

This commit is contained in:
Adam Johnson 2020-01-20 10:32:31 +00:00 committed by Mariusz Felisiak
parent 7e8339748c
commit 382af9b141
2 changed files with 3 additions and 1 deletions

View File

@ -2100,6 +2100,8 @@ that fail constraints such as duplicate unique values. Enabling this parameter
disables setting the primary key on each model instance (if the database disables setting the primary key on each model instance (if the database
normally supports it). normally supports it).
Returns ``objs`` as cast to a list, in the same order as provided.
``bulk_update()`` ``bulk_update()``
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View File

@ -26,7 +26,7 @@ class BulkCreateTests(TestCase):
def test_simple(self): def test_simple(self):
created = Country.objects.bulk_create(self.data) created = Country.objects.bulk_create(self.data)
self.assertEqual(len(created), 4) self.assertEqual(created, self.data)
self.assertQuerysetEqual(Country.objects.order_by("-name"), [ self.assertQuerysetEqual(Country.objects.order_by("-name"), [
"United States of America", "The Netherlands", "Germany", "Czech Republic" "United States of America", "The Netherlands", "Germany", "Czech Republic"
], attrgetter("name")) ], attrgetter("name"))