diff options
| author | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-04-08 18:10:14 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-04-10 15:55:30 +0200 |
| commit | f075a19e856ced33ddfb0e1330b5c277ddb14bfe (patch) | |
| tree | e0ca7652dbcdfde69eb70c4add312b8e128d59d9 /tests/model_fields/test_generatedfield.py | |
| parent | 58061fd2b4c4b66c0fd3db8026c8b5e369ed9ec3 (diff) | |
[5.0.x] Fixed #35350 -- Fixed save() with pk set on models with GeneratedFields.
Thanks Matt Hegarty for the report and Simon Charette and Natalia Bidart for the reviews.
Regression in f333e35.
Backport of 8b53560eea9f10a1271d3bdf765dc6f969c7d9d5 from main.
Diffstat (limited to 'tests/model_fields/test_generatedfield.py')
| -rw-r--r-- | tests/model_fields/test_generatedfield.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/model_fields/test_generatedfield.py b/tests/model_fields/test_generatedfield.py index 641ce591e4..2fbfe3c82a 100644 --- a/tests/model_fields/test_generatedfield.py +++ b/tests/model_fields/test_generatedfield.py @@ -207,6 +207,12 @@ class GeneratedFieldTestMixin: m.refresh_from_db() self.assertEqual(m.field, 8) + def test_save_model_with_pk(self): + m = self.base_model(pk=1, a=1, b=2) + m.save() + m = self._refresh_if_needed(m) + self.assertEqual(m.field, 3) + def test_save_model_with_foreign_key(self): fk_object = Foo.objects.create(a="abc", d=Decimal("12.34")) m = self.base_model(a=1, b=2, fk=fk_object) |
