diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2012-11-24 00:28:20 +0200 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2012-11-24 01:19:17 +0200 |
| commit | 625dc3f0722d80eaffacc39171ea7337ab089ae4 (patch) | |
| tree | cdf2c73de60328e686fa3d88b0bfd31211f60e01 /tests/regressiontests | |
| parent | 6a00c1968b78484dc821d56567443c28fad6dfbc (diff) | |
[1.5.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
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/bulk_create/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/regressiontests/bulk_create/tests.py b/tests/regressiontests/bulk_create/tests.py index 5d61242b9b..7cd74d1b47 100644 --- a/tests/regressiontests/bulk_create/tests.py +++ b/tests/regressiontests/bulk_create/tests.py @@ -82,6 +82,14 @@ class BulkCreateTests(TestCase): with self.assertRaises(ValueError): Country.objects.bulk_create([valid_country, invalid_country]) + 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 = [] |
