Permalink
Browse files

Ensure bulk_create returns what it is supposed to.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16791 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent e95d0af commit f2bc919ec00457fd53f093af53ab71c7f1bcfbcd @alex alex committed Sep 10, 2011
Showing with 3 additions and 1 deletion.
  1. +1 −0 django/db/models/query.py
  2. +2 −1 tests/regressiontests/bulk_create/tests.py
View
1 django/db/models/query.py
@@ -388,6 +388,7 @@ def bulk_create(self, objs):
self.model._base_manager._insert(objs_with_pk, fields=fields, using=self.db)
if objs_without_pk:
self.model._base_manager._insert(objs_without_pk, fields=[f for f in fields if not isinstance(f, AutoField)], using=self.db)
+ return objs
def get_or_create(self, **kwargs):
"""
View
3 tests/regressiontests/bulk_create/tests.py
@@ -17,7 +17,8 @@ def setUp(self):
]
def test_simple(self):
- Country.objects.bulk_create(self.data)
+ created = Country.objects.bulk_create(self.data)
+ self.assertEqual(len(created), 4)
self.assertQuerysetEqual(Country.objects.order_by("-name"), [
"United States of America", "The Netherlands", "Germany", "Czech Republic"
], attrgetter("name"))

0 comments on commit f2bc919

Please sign in to comment.