summaryrefslogtreecommitdiff
path: root/tests/bulk_create
diff options
context:
space:
mode:
authorSjoerd Job Postmus <sjoerdjob@sjec.nl>2016-08-05 23:57:55 +0200
committerTim Graham <timograham@gmail.com>2016-08-06 10:24:57 -0400
commit3246d2b4bb981a8d782a349a99e9b89206028cee (patch)
tree211362f1af89a89574b86eb5849f8d8b2af20f78 /tests/bulk_create
parentfc8f097117af7ada616fad20ae5b417fcf740413 (diff)
downloaddjango-3246d2b4bb981a8d782a349a99e9b89206028cee.tar.gz
Fixed #27026 -- Fixed state initialization of bulk_create() objects if can_return_ids_from_bulk_insert.
Diffstat (limited to 'tests/bulk_create')
-rw-r--r--tests/bulk_create/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py
index a7eb725f55..e6d85cb815 100644
--- a/tests/bulk_create/tests.py
+++ b/tests/bulk_create/tests.py
@@ -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)