Author: Alex
Date: 2011-09-10 14:46:59 -0700 (Sat, 10 Sep 2011)
New Revision: 16792
Modified:
django/trunk/django/db/models/query.py
django/trunk/tests/regressiontests/bulk_create/tests.py
Log:
Ensure bulk_create returns the right value if the argument is an empty list.
Modified: django/trunk/django/db/models/query.py
===================================================================
--- django/trunk/django/db/models/query.py 2011-09-10 21:44:57 UTC (rev
16791)
+++ django/trunk/django/db/models/query.py 2011-09-10 21:46:59 UTC (rev
16792)
@@ -372,7 +372,7 @@
if self.model._meta.parents:
raise ValueError("Can't bulk create an inherited model")
if not objs:
- return
+ return objs
self._for_write = True
connection = connections[self.db]
fields = self.model._meta.local_fields
Modified: django/trunk/tests/regressiontests/bulk_create/tests.py
===================================================================
--- django/trunk/tests/regressiontests/bulk_create/tests.py 2011-09-10
21:44:57 UTC (rev 16791)
+++ django/trunk/tests/regressiontests/bulk_create/tests.py 2011-09-10
21:46:59 UTC (rev 16792)
@@ -23,6 +23,10 @@
"United States of America", "The Netherlands", "Germany", "Czech
Republic"
], attrgetter("name"))
+ created = Country.objects.bulk_create([])
+ self.assertEqual(created, [])
+ self.assertEqual(Country.objects.count(), 4)
+
@skipUnlessDBFeature("has_bulk_insert")
def test_efficiency(self):
with self.assertNumQueries(1):
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.