mirror of
https://github.com/django/django.git
synced 2025-07-13 00:05:16 +00:00
Fixed #30581 -- Added support for Meta.constraints validation.
Thanks Simon Charette, Keryn Knight, and Mariusz Felisiak for reviews.
This commit is contained in:
parent
441103a04d
commit
667105877e
17 changed files with 852 additions and 88 deletions
|
@ -12,7 +12,7 @@ PostgreSQL supports additional data integrity constraints available from the
|
|||
``ExclusionConstraint``
|
||||
=======================
|
||||
|
||||
.. class:: ExclusionConstraint(*, name, expressions, index_type=None, condition=None, deferrable=None, include=None, opclasses=())
|
||||
.. class:: ExclusionConstraint(*, name, expressions, index_type=None, condition=None, deferrable=None, include=None, opclasses=(), violation_error_message=None)
|
||||
|
||||
Creates an exclusion constraint in the database. Internally, PostgreSQL
|
||||
implements exclusion constraints using indexes. The default index type is
|
||||
|
@ -27,6 +27,14 @@ PostgreSQL supports additional data integrity constraints available from the
|
|||
:exc:`~django.db.IntegrityError` is raised. Similarly, when update
|
||||
conflicts with an existing row.
|
||||
|
||||
Exclusion constraints are checked during the :ref:`model validation
|
||||
<validating-objects>`.
|
||||
|
||||
.. versionchanged:: 4.1
|
||||
|
||||
In older versions, exclusion constraints were not checked during model
|
||||
validation.
|
||||
|
||||
``name``
|
||||
--------
|
||||
|
||||
|
@ -165,6 +173,15 @@ creates an exclusion constraint on ``circle`` using ``circle_ops``.
|
|||
:class:`OpClass() <django.contrib.postgres.indexes.OpClass>` in
|
||||
:attr:`~ExclusionConstraint.expressions`.
|
||||
|
||||
``violation_error_message``
|
||||
---------------------------
|
||||
|
||||
.. versionadded:: 4.1
|
||||
|
||||
The error message used when ``ValidationError`` is raised during
|
||||
:ref:`model validation <validating-objects>`. Defaults to
|
||||
:attr:`.BaseConstraint.violation_error_message`.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue