From c7dcb1d808597e0806fb352bb5ddc4b58c452f4c Mon Sep 17 00:00:00 2001 From: Anssi Kääriäinen Date: Sat, 24 Nov 2012 00:28:20 +0200 Subject: [1.4.x] Fixed SQLite's collapsing of same-valued instances in bulk_create SQLite used INSERT INTO tbl SELECT %s UNION SELECT %s, the problem was that there should have been UNION ALL instead of UNION. Refs #19351 Backpatch of a27582484cf814554907d2d1ad077852de36963f --- tests/regressiontests/bulk_create/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/bulk_create/tests.py b/tests/regressiontests/bulk_create/tests.py index b4c3e7f17f..f75d983a06 100644 --- a/tests/regressiontests/bulk_create/tests.py +++ b/tests/regressiontests/bulk_create/tests.py @@ -59,6 +59,14 @@ class BulkCreateTests(TestCase): "CA", "IL", "ME", "NY", ], attrgetter("two_letter_code")) + def test_batch_same_vals(self): + # Sqlite had a problem where all the same-valued models were + # collapsed to one insert. + Restaurant.objects.bulk_create([ + Restaurant(name='foo') for i in range(0, 2) + ]) + self.assertEqual(Restaurant.objects.count(), 2) + def test_large_batch(self): with override_settings(DEBUG=True): connection.queries = [] -- cgit v1.3