mirror of
https://github.com/django/django.git
synced 2025-01-03 15:06:09 +00:00
Refs #34964 -- Doc'd that Q expression order is preserved.
This commit is contained in:
parent
107aa76bcf
commit
7714ccfeae
@ -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')``
|
For example, ``CheckConstraint(check=Q(age__gte=18), name='age_gte_18')``
|
||||||
ensures the age field is never less than 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
|
.. admonition:: Oracle
|
||||||
|
|
||||||
Checks with nullable fields on Oracle must include a condition allowing for
|
Checks with nullable fields on Oracle must include a condition allowing for
|
||||||
|
Loading…
Reference in New Issue
Block a user