mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Refs #11964 -- Changed CheckConstraint() signature to use keyword-only arguments.
Also renamed the `constraint` argument to `check` to better represent which part of the constraint the provided `Q` object represents.
This commit is contained in:
parent
0bf7b25f8f
commit
9142bebff2
9 changed files with 34 additions and 34 deletions
|
@ -23,20 +23,20 @@ explains the API references of :class:`CheckConstraint`.
|
|||
``CheckConstraint`` options
|
||||
===========================
|
||||
|
||||
.. class:: CheckConstraint(constraint, name)
|
||||
.. class:: CheckConstraint(*, check, name)
|
||||
|
||||
Creates a check constraint in the database.
|
||||
|
||||
``constraint``
|
||||
--------------
|
||||
``check``
|
||||
---------
|
||||
|
||||
.. attribute:: CheckConstraint.constraint
|
||||
.. attribute:: CheckConstraint.check
|
||||
|
||||
A :class:`Q` object that specifies the condition you want the constraint to
|
||||
A :class:`Q` object that specifies the check you want the constraint to
|
||||
enforce.
|
||||
|
||||
For example ``CheckConstraint(Q(age__gte=18), 'age_gte_18')`` ensures the age
|
||||
field is never less than 18.
|
||||
For example ``CheckConstraint(check=Q(age__gte=18), name='age_gte_18')``
|
||||
ensures the age field is never less than 18.
|
||||
|
||||
``name``
|
||||
--------
|
||||
|
|
|
@ -469,7 +469,7 @@ Django quotes column and table names behind the scenes.
|
|||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.CheckConstraint(models.Q(age__gte=18), 'age_gte_18'),
|
||||
models.CheckConstraint(check=models.Q(age__gte=18), name='age_gte_18'),
|
||||
]
|
||||
|
||||
``verbose_name``
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue