diff options
| author | Simon Charette <charette.s@gmail.com> | 2025-01-13 22:04:33 -0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-14 16:21:19 +0100 |
| commit | f07360e8087d3b403d1d12ff696da3138116055a (patch) | |
| tree | 2317665d4cecd2be7e35da8a1756ef51aa710dd2 /tests/update_only_fields | |
| parent | 161e79d277ffe8b79b15ad51cb0d23de54270202 (diff) | |
Refs #36075 -- Adjusted MTI handling of _non_pk_concrete_field_names.
Regression in bf7b17d16d3978b2e1cee4a0f7ce8840bd1a8dc4.
Thanks Sage Abdullah for the report.
Diffstat (limited to 'tests/update_only_fields')
| -rw-r--r-- | tests/update_only_fields/tests.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/update_only_fields/tests.py b/tests/update_only_fields/tests.py index a6a5b7cb8e..43f3e1fd16 100644 --- a/tests/update_only_fields/tests.py +++ b/tests/update_only_fields/tests.py @@ -7,8 +7,8 @@ from .models import Account, Employee, Person, Profile, ProxyEmployee class UpdateOnlyFieldsTests(TestCase): msg = ( - "The following fields do not exist in this model, are m2m fields, or " - "are non-concrete fields: %s" + "The following fields do not exist in this model, are m2m " + "fields, primary keys, or are non-concrete fields: %s" ) def test_update_fields_basic(self): @@ -308,3 +308,13 @@ class UpdateOnlyFieldsTests(TestCase): profile_boss = Profile.objects.create(name="Boss", salary=3000) with self.assertRaisesMessage(ValueError, self.msg % "non_concrete"): profile_boss.save(update_fields=["non_concrete"]) + + def test_update_pk_field(self): + person_boss = Person.objects.create(name="Boss", gender="F") + with self.assertRaisesMessage(ValueError, self.msg % "id"): + person_boss.save(update_fields=["id"]) + + def test_update_inherited_pk_field(self): + employee_boss = Employee.objects.create(name="Boss", gender="F") + with self.assertRaisesMessage(ValueError, self.msg % "id"): + employee_boss.save(update_fields=["id"]) |
