diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-01-22 22:21:09 -0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-28 10:19:43 +0000 |
| commit | 72ff18d41cfb004ae180bdf87fd8bad93041c691 (patch) | |
| tree | b4b23ff1178ca8bc99a0ef36781086714811a855 /tests | |
| parent | d9af197801376fae178761cac12d57178a738cf4 (diff) | |
Fixed #36120 -- Raised FieldError when targeting a composite primary key field with QuerySet.update().
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/composite_pk/test_update.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/composite_pk/test_update.py b/tests/composite_pk/test_update.py index ec770230fc..5bc53f1fe1 100644 --- a/tests/composite_pk/test_update.py +++ b/tests/composite_pk/test_update.py @@ -1,3 +1,4 @@ +from django.core.exceptions import FieldError from django.db import connection from django.test import TestCase @@ -175,3 +176,9 @@ class CompositePKUpdateTests(TestCase): with self.assertRaisesMessage(ValueError, msg): Comment.objects.update(user=User()) + + def test_cant_update_pk_field(self): + qs = Comment.objects.filter(user__email=self.user_1.email) + msg = "Composite primary key fields must be updated individually." + with self.assertRaisesMessage(FieldError, msg): + qs.update(pk=(1, 10)) |
