summaryrefslogtreecommitdiff
path: root/tests/regressiontests/bulk_create/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regressiontests/bulk_create/tests.py')
-rw-r--r--tests/regressiontests/bulk_create/tests.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/regressiontests/bulk_create/tests.py b/tests/regressiontests/bulk_create/tests.py
index 284ea9fdd9..0b55f637a4 100644
--- a/tests/regressiontests/bulk_create/tests.py
+++ b/tests/regressiontests/bulk_create/tests.py
@@ -2,7 +2,7 @@ from __future__ import absolute_import
from operator import attrgetter
-from django.test import TestCase, skipUnlessDBFeature
+from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .models import Country, Restaurant, Pizzeria, State
@@ -56,4 +56,16 @@ class BulkCreateTests(TestCase):
])
self.assertQuerysetEqual(State.objects.order_by("two_letter_code"), [
"CA", "IL", "ME", "NY",
- ], attrgetter("two_letter_code")) \ No newline at end of file
+ ], attrgetter("two_letter_code"))
+
+ @skipIfDBFeature('allows_primary_key_0')
+ def test_zero_as_autoval(self):
+ """
+ Zero as id for AutoField should raise exception in MySQL, because MySQL
+ does not allow zero for automatic primary key.
+ """
+
+ valid_country = Country(name='Germany', iso_two_letter='DE')
+ invalid_country = Country(id=0, name='Poland', iso_two_letter='PL')
+ with self.assertRaises(ValueError):
+ Country.objects.bulk_create([valid_country, invalid_country])