mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[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 a27582484c
This commit is contained in:
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user