From efec74b90868c2e611f863bf4301d92ce08067e8 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sat, 25 Jan 2025 19:13:13 -0500 Subject: Fixed #36122 -- Raised FieldError when updating with composite reference value. Thanks Jacob Walls for the report and test. --- django/db/models/sql/compiler.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 6f90f11f1b..04372c509e 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -2019,6 +2019,11 @@ class SQLUpdateCompiler(SQLCompiler): "Window expressions are not allowed in this query " "(%s=%r)." % (field.name, val) ) + if isinstance(val, ColPairs): + raise FieldError( + "Composite primary keys expressions are not allowed " + "in this query (%s=F('pk'))." % field.name + ) elif hasattr(val, "prepare_database_save"): if field.remote_field: val = val.prepare_database_save(field) -- cgit v1.3