diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2024-05-04 17:11:07 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-05-07 12:15:27 +0200 |
| commit | ceea86baa36b91d0002911770340a2d7bd4f64b7 (patch) | |
| tree | 2e0de1367b61fb44caef8834df45afe9d2a0a139 /tests/basic | |
| parent | 34a503162fe222033a1cd3249bccad014fcd1d20 (diff) | |
Fixed #35425 -- Avoided INSERT with force_update and explicit pk.
Affected models where the primary key field is defined with a
default or db_default, such as UUIDField.
Diffstat (limited to 'tests/basic')
| -rw-r--r-- | tests/basic/tests.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py index bda59d82fa..38fb9ca200 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -186,6 +186,12 @@ class ModelInstanceCreationTests(TestCase): with self.assertNumQueries(1): PrimaryKeyWithDefault().save() + def test_save_primary_with_default_force_update(self): + # An UPDATE attempt is made if explicitly requested. + obj = PrimaryKeyWithDefault.objects.create() + with self.assertNumQueries(1): + PrimaryKeyWithDefault(uuid=obj.pk).save(force_update=True) + def test_save_primary_with_db_default(self): # An UPDATE attempt is skipped when a primary key has db_default. with self.assertNumQueries(1): |
