From f030236a86a64a4befd3cc8093e2bbeceef52a31 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Sun, 12 May 2024 20:10:55 +0200 Subject: Fixed #35275 -- Fixed Meta.constraints validation crash on UniqueConstraint with OpClass(). This also introduces Expression.constraint_validation_compatible that allows specifying that expression should be ignored during a constraint validation. --- docs/ref/models/expressions.txt | 9 +++++++++ docs/releases/5.1.txt | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'docs') diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt index 67baef7dfc..f630142294 100644 --- a/docs/ref/models/expressions.txt +++ b/docs/ref/models/expressions.txt @@ -1058,6 +1058,15 @@ calling the appropriate methods on the wrapped expression. Tells Django that this expression can be used in :attr:`Field.db_default`. Defaults to ``False``. + .. attribute:: constraint_validation_compatible + + .. versionadded:: 5.1 + + Tells Django that this expression can be used during a constraint + validation. Expressions with ``constraint_validation_compatible`` set + to ``False`` must have only one source expression. Defaults to + ``True``. + .. attribute:: contains_aggregate Tells Django that this expression contains an aggregate and that a diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt index f2a6bccb0c..f068f3e96b 100644 --- a/docs/releases/5.1.txt +++ b/docs/releases/5.1.txt @@ -281,6 +281,10 @@ Models reload a model's value. This can be used to lock the row before reloading or to select related objects. +* The new :attr:`.Expression.constraint_validation_compatible` attribute allows + specifying that the expression should be ignored during a constraint + validation. + Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.3