﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36068	bulk_create() update_fields argument accepts fields participating in a composite primary key	Jacob Walls	Jacob Walls	"`bulk_create()` [https://github.com/django/django/blob/40d5516385448a73426aad396778f369a363eda9/tests/bulk_create/tests.py#L540 rejects] primary key fields provided to the `update_fields` argument. I think I would expect any fields participating in a composite primary key to also be subject to that constraint.

Failing test:

{{{#!diff
diff --git a/tests/composite_pk/test_create.py b/tests/composite_pk/test_create.py
index 7c9925b946..77a84fc53d 100644
--- a/tests/composite_pk/test_create.py
+++ b/tests/composite_pk/test_create.py
@@ -77,6 +77,19 @@ class CompositePKCreateTests(TestCase):
         self.assertEqual(obj_3.pk, (obj_3.tenant_id, obj_3.id))
         self.assertEqual(obj_3.email, ""user8214@example.com"")
 
+    def test_bulk_create_user_with_disallowed_update_fields(self):
+        objs = [User(tenant=self.tenant, id=8291, email=""user8291@example.com"")] * 2
+        msg = ""bulk_create() cannot be used with primary keys in update fields""
+        with self.assertRaisesMessage(ValueError, msg):
+            User.objects.bulk_create(
+                objs,
+                update_conflicts=True,
+                update_fields=[""tenant_id""],
+                unique_fields=[""id"", ""tenant_id""],
+            )
+        # instead produces:
+        # [<User: User object ((1, 8291))>, <User: User object ((1, 8291))>]
+
     def test_get_or_create_user(self):
         test_cases = (
             {
}}}"	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
