Fixed #30062 -- Added support for unique conditional constraints.

This commit is contained in:
Paveł Tyślacki 2018-12-27 22:21:59 +03:00 committed by Tim Graham
parent 1e837c4b23
commit b69f8eb04c
8 changed files with 291 additions and 26 deletions

View file

@ -69,3 +69,17 @@ date.
.. attribute:: UniqueConstraint.name
The name of the constraint.
``condition``
-------------
.. attribute:: UniqueConstraint.condition
A :class:`Q` object that specifies the condition you want the constraint to
enforce.
For example, ``UniqueConstraint(fields=['user'], condition=Q(status='DRAFT')``
ensures that each user only has one draft.
These conditions have the same database restrictions as
:attr:`Index.condition`.