Fixed #21517 -- Added unit test for non-autoincrement primary key with value 0.

This commit is contained in:
Vajrasky Kok 2013-11-27 23:01:18 +08:00 committed by Tim Graham
parent 077af42139
commit d1df395f3a
1 changed files with 7 additions and 0 deletions

View File

@ -153,6 +153,13 @@ class CustomPKTests(TestCase):
with transaction.atomic(): with transaction.atomic():
Employee.objects.create(employee_code=123, first_name="Fred", last_name="Jones") Employee.objects.create(employee_code=123, first_name="Fred", last_name="Jones")
def test_zero_non_autoincrement_pk(self):
Employee.objects.create(
employee_code=0, first_name="Frank", last_name="Jones"
)
employee = Employee.objects.get(pk=0)
self.assertEqual(employee.employee_code, 0)
def test_custom_field_pk(self): def test_custom_field_pk(self):
# Regression for #10785 -- Custom fields can be used for primary keys. # Regression for #10785 -- Custom fields can be used for primary keys.
new_bar = Bar.objects.create() new_bar = Bar.objects.create()