1
0
mirror of https://github.com/django/django.git synced 2025-10-27 15:46:10 +00:00

[1.10.x] Fixed #27026 -- Fixed state initialization of bulk_create() objects if can_return_ids_from_bulk_insert.

Backport of 3246d2b4bb from master
This commit is contained in:
Sjoerd Job Postmus
2016-08-05 23:57:55 +02:00
committed by Tim Graham
parent d68b145a6f
commit 2f18cbc313
3 changed files with 19 additions and 2 deletions

View File

@@ -217,3 +217,13 @@ class BulkCreateTests(TestCase):
self.assertEqual(Country.objects.get(pk=countries[1].pk), countries[1])
self.assertEqual(Country.objects.get(pk=countries[2].pk), countries[2])
self.assertEqual(Country.objects.get(pk=countries[3].pk), countries[3])
@skipUnlessDBFeature('can_return_ids_from_bulk_insert')
def test_set_state(self):
country_nl = Country(name='Netherlands', iso_two_letter='NL')
country_be = Country(name='Belgium', iso_two_letter='BE')
Country.objects.bulk_create([country_nl])
country_be.save()
# Objects save via bulk_create() and save() should have equal state.
self.assertEqual(country_nl._state.adding, country_be._state.adding)
self.assertEqual(country_nl._state.db, country_be._state.db)