summaryrefslogtreecommitdiff
path: root/tests/model_fields/test_generatedfield.py
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-04-08 18:10:14 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-04-10 15:43:50 +0200
commit8b53560eea9f10a1271d3bdf765dc6f969c7d9d5 (patch)
treeabf15e8ebde434ec224faaca974404140bfb4058 /tests/model_fields/test_generatedfield.py
parentca5cd3e3e8e53f15e68ccd727ec8fe719cc48099 (diff)
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.
Diffstat (limited to 'tests/model_fields/test_generatedfield.py')
-rw-r--r--tests/model_fields/test_generatedfield.py6
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)