summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sanders <shang.xiao.sanders@gmail.com>2023-11-16 21:56:36 +1100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-02-28 13:06:30 +0100
commita8de04f8db470d1c43f945f28a00fb49b1f2ca80 (patch)
treea8ff105dd38ebcdabee449af72de2758f1d27292
parentb1f2833bc406529b86f6152354c3798a6f092b2b (diff)
[5.0.x] Refs #34964 -- Doc'd that Q expression order is preserved.
Backport of 7714ccfeae969aca52ad46c1d69a13fac4086c08 from main
-rw-r--r--docs/ref/models/constraints.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt
index cc308cedf2..0d6d87afbe 100644
--- a/docs/ref/models/constraints.txt
+++ b/docs/ref/models/constraints.txt
@@ -119,6 +119,18 @@ specifies the check you want the constraint to enforce.
For example, ``CheckConstraint(check=Q(age__gte=18), name='age_gte_18')``
ensures the age field is never less than 18.
+.. admonition:: Expression order
+
+ ``Q`` argument order is not necessarily preserved, however the order of
+ ``Q`` expressions themselves are preserved. This may be important for
+ databases that preserve check constraint expression order for performance
+ reasons. For example, use the following format if order matters::
+
+ CheckConstraint(
+ check=Q(age__gte=18) & Q(expensive_check=condition),
+ name="age_gte_18_and_others",
+ )
+
.. admonition:: Oracle
Checks with nullable fields on Oracle must include a condition allowing for