summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2025-01-22 22:21:09 -0500
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-01-28 11:20:51 +0100
commit791ed4fd97a1a58401cd911dd69a32808fb86f79 (patch)
tree418cf23fd2eb06718ed633686fa528c2bdb6c1b5 /tests
parent720ef7a867eab1491f5789fe39b3431a498b2b89 (diff)
[5.2.x] Fixed #36120 -- Raised FieldError when targeting a composite primary key field with QuerySet.update().
Backport of 72ff18d41cfb004ae180bdf87fd8bad93041c691 from main.
Diffstat (limited to 'tests')
-rw-r--r--tests/composite_pk/test_update.py7
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))