summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2024-02-26 00:14:26 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-03-01 07:15:32 +0100
commitdaf7d482dbaaa2604241a994c49f442fa15142c1 (patch)
tree65eae557dbe8694e03130cc17259a792792c95b7 /docs
parentf82c67aa217c8dd4320ef697b04a6da1681aa799 (diff)
Refs #35234 -- Deprecated CheckConstraint.check in favor of .condition.
Once the deprecation period ends CheckConstraint.check() can become the documented method that performs system checks for BaseConstraint subclasses.
Diffstat (limited to 'docs')
-rw-r--r--docs/internals/deprecation.txt2
-rw-r--r--docs/ref/models/constraints.txt22
-rw-r--r--docs/ref/models/options.txt2
-rw-r--r--docs/releases/3.1.txt2
-rw-r--r--docs/releases/5.1.txt3
5 files changed, 20 insertions, 11 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 8072075864..c0965f676b 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -77,6 +77,8 @@ details on these changes.
* ``django.urls.register_converter()`` will no longer allow overriding existing
converters.
+* The ``check`` keyword argument of ``CheckConstraint`` will be removed.
+
.. _deprecation-removed-in-5.1:
5.1
diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt
index 0d6d87afbe..fa6edfd766 100644
--- a/docs/ref/models/constraints.txt
+++ b/docs/ref/models/constraints.txt
@@ -26,7 +26,7 @@ option.
(including ``name``) each time. To work around name collisions, part of the
name may contain ``'%(app_label)s'`` and ``'%(class)s'``, which are
replaced, respectively, by the lowercased app label and class name of the
- concrete model. For example ``CheckConstraint(check=Q(age__gte=18),
+ concrete model. For example ``CheckConstraint(condition=Q(age__gte=18),
name='%(app_label)s_%(class)s_is_adult')``.
.. admonition:: Validation of Constraints
@@ -104,19 +104,19 @@ This method must be implemented by a subclass.
``CheckConstraint``
===================
-.. class:: CheckConstraint(*, check, name, violation_error_code=None, violation_error_message=None)
+.. class:: CheckConstraint(*, condition, name, violation_error_code=None, violation_error_message=None)
Creates a check constraint in the database.
-``check``
----------
+``condition``
+-------------
-.. attribute:: CheckConstraint.check
+.. attribute:: CheckConstraint.condition
A :class:`Q` object or boolean :class:`~django.db.models.Expression` that
-specifies the check you want the constraint to enforce.
+specifies the conditional check you want the constraint to enforce.
-For example, ``CheckConstraint(check=Q(age__gte=18), name='age_gte_18')``
+For example, ``CheckConstraint(condition=Q(age__gte=18), name='age_gte_18')``
ensures the age field is never less than 18.
.. admonition:: Expression order
@@ -127,7 +127,7 @@ ensures the age field is never less than 18.
reasons. For example, use the following format if order matters::
CheckConstraint(
- check=Q(age__gte=18) & Q(expensive_check=condition),
+ condition=Q(age__gte=18) & Q(expensive_check=condition),
name="age_gte_18_and_others",
)
@@ -138,7 +138,11 @@ ensures the age field is never less than 18.
to behave the same as check constraints validation. For example, if ``age``
is a nullable field::
- CheckConstraint(check=Q(age__gte=18) | Q(age__isnull=True), name="age_gte_18")
+ CheckConstraint(condition=Q(age__gte=18) | Q(age__isnull=True), name="age_gte_18")
+
+.. deprecated:: 5.1
+
+ The ``check`` attribute is deprecated in favor of ``condition``.
``UniqueConstraint``
====================
diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt
index 909577be6c..3433d0730f 100644
--- a/docs/ref/models/options.txt
+++ b/docs/ref/models/options.txt
@@ -467,7 +467,7 @@ not be looking at your Django code. For example::
class Meta:
constraints = [
- models.CheckConstraint(check=models.Q(age__gte=18), name="age_gte_18"),
+ models.CheckConstraint(condition=models.Q(age__gte=18), name="age_gte_18"),
]
``verbose_name``
diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt
index a872326200..704cf3e6d1 100644
--- a/docs/releases/3.1.txt
+++ b/docs/releases/3.1.txt
@@ -388,7 +388,7 @@ Models
``OneToOneField`` emulates the behavior of the SQL constraint ``ON DELETE
RESTRICT``.
-* :attr:`.CheckConstraint.check` now supports boolean expressions.
+* ``CheckConstraint.check`` now supports boolean expressions.
* The :meth:`.RelatedManager.add`, :meth:`~.RelatedManager.create`, and
:meth:`~.RelatedManager.set` methods now accept callables as values in the
diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt
index 9a2f2fc6cc..b2377608f0 100644
--- a/docs/releases/5.1.txt
+++ b/docs/releases/5.1.txt
@@ -422,6 +422,9 @@ Miscellaneous
* Overriding existing converters with ``django.urls.register_converter()`` is
deprecated.
+* The ``check`` keyword argument of ``CheckConstraint`` is deprecated in favor
+ of ``condition``.
+
Features removed in 5.1
=======================