summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-05-06 13:57:20 -0400
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-05-16 08:13:57 +0200
commite03e5c751c56db5f4cb99e142c92d7d8db3a5463 (patch)
tree474e4baf6ac38c2e940552a167bc8562eae142b3 /tests/model_fields
parent0b2ed4f7c8396c8d9aa8428a40e6b25c31312889 (diff)
Fixed #33312 -- Raised explicit exception when copying deferred model instances.
Previously save() would crash with an attempted forced update message, and both save(force_insert=True) and bulk_create() would crash with DoesNotExist errors trying to retrieve rows with an empty primary key (id IS NULL). Implementing deferred field model instance copying might be doable in certain cases (e.g. when all the deferred fields are db generated) but that's not trivial to implement in a backward compatible way. Thanks Adam Sołtysik for the report and test and Clifford for the review.
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/test_generatedfield.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/model_fields/test_generatedfield.py b/tests/model_fields/test_generatedfield.py
index 9bc96a86bb..b6a933451d 100644
--- a/tests/model_fields/test_generatedfield.py
+++ b/tests/model_fields/test_generatedfield.py
@@ -180,7 +180,7 @@ class GeneratedFieldTestMixin:
def test_unsaved_error(self):
m = self.base_model(a=1, b=2)
- msg = "Cannot read a generated field from an unsaved model."
+ msg = "Cannot retrieve deferred field 'field' from an unsaved model."
with self.assertRaisesMessage(AttributeError, msg):
m.field