diff options
| author | Simon Charette <charette.s@gmail.com> | 2025-01-25 19:13:13 -0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-28 13:19:36 +0100 |
| commit | d4d2e09f19e5d764b8b4df34f048f8babf670e8e (patch) | |
| tree | d7db6898f70be876a8ec1431559e3de0854adf9b /django/db/models/sql/compiler.py | |
| parent | 9fe17213a66ffc58a71e1fd7d50dbabb3a0c499c (diff) | |
[5.2.x] Fixed #36122 -- Raised FieldError when updating with composite reference value.
Thanks Jacob Walls for the report and test.
Backport of efec74b90868c2e611f863bf4301d92ce08067e8 from main.
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 5 |
1 files changed, 5 insertions, 0 deletions
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) |
