Explorar o código

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

Adam Johnson %!s(int64=5) %!d(string=hai) anos
pai
achega
382af9b141
Modificáronse 2 ficheiros con 3 adicións e 1 borrados
  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
 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()``
 ~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~
 
 

+ 1 - 1
tests/bulk_create/tests.py

@@ -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"))