Commit f2bc919e authored by Alex Gaynor's avatar Alex Gaynor
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
parent e95d0afe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -388,6 +388,7 @@ class QuerySet(object):
                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):
        """
+2 −1
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@ class BulkCreateTests(TestCase):
        ]

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