Skip to content

Commit

Permalink
[5.0.x] Refs #34964 -- Doc'd that Q expression order is preserved.
Browse files Browse the repository at this point in the history
Backport of 7714ccf from main
  • Loading branch information
shangxiao authored and felixxm committed Feb 28, 2024
1 parent b1f2833 commit a8de04f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/ref/models/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a8de04f

Please sign in to comment.