mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[5.2.x] Fixed #36120 -- Raised FieldError when targeting a composite primary key field with QuerySet.update().
Backport of 72ff18d41c from main.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user