Browse Source

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

Adam Johnson 5 years ago
parent
commit
382af9b141
2 changed files with 3 additions and 1 deletions
  1. 2 0
      docs/ref/models/querysets.txt
  2. 1 1
      tests/bulk_create/tests.py

+ 2 - 0
docs/ref/models/querysets.txt

@@ -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
 normally supports it).
 
+Returns ``objs`` as cast to a list, in the same order as provided.
+
 ``bulk_update()``
 ~~~~~~~~~~~~~~~~~
 

+ 1 - 1
tests/bulk_create/tests.py

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