[Django] #30547: Specify what happens during model validation with Meta.constraints

17 views
Skip to first unread message

Django

unread,
Jun 6, 2019, 6:51:10 AM6/6/19
to django-...@googlegroups.com
#30547: Specify what happens during model validation with Meta.constraints
-------------------------------------+-------------------------------------
Reporter: Dirk | Owner: nobody
Groten |
Type: | Status: new
Cleanup/optimization |
Component: | Version: 2.2
Documentation | Keywords: constraints,
Severity: Normal | UniqueConstraint
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The current [https://docs.djangoproject.com/en/2.2/ref/models/constraints/
constraints reference] does not mention whether or not a
**ValidationError** is raised during model validation if a constraint
fails. The documentation only mentions that a database constraint is
created.

However, for the soon to be deprecated `unique_together`, there is a
reference to model validation.

As far as I can see, a `UniqueConstraint` causes `validate_unique()` to
check for uniqueness and raises a **ValidationError**. But a
`CheckConstraint` does not cause a **ValidationError** when the model is
validated. I believe it's important to mention this in the documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/30547>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 6, 2019, 7:34:13 AM6/6/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:
Keywords: constraints, | Triage Stage: Accepted
UniqueConstraint |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Unreviewed => Accepted
* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:1>

Django

unread,
Jun 13, 2019, 12:35:00 PM6/13/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: assigned

Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:
Keywords: constraints, | Triage Stage: Accepted
UniqueConstraint |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Swatantra):

* owner: nobody => Swatantra
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:2>

Django

unread,
Jun 17, 2019, 5:18:41 AM6/17/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:
Keywords: constraints, | Triage Stage: Accepted
UniqueConstraint |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/11478 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:3>

Django

unread,
Jun 19, 2019, 6:04:27 AM6/19/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:
Keywords: constraints, | Triage Stage: Accepted
UniqueConstraint |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:4>

Django

unread,
Jun 20, 2019, 3:28:22 AM6/20/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:
Keywords: constraints, | Triage Stage: Ready for
UniqueConstraint | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:5>

Django

unread,
Jun 20, 2019, 4:45:08 AM6/20/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: closed

Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed

Keywords: constraints, | Triage Stage: Ready for
UniqueConstraint | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton.gibson@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"00169bc36156d4a32546229bf39de91213709eaf" 00169bc3]:
{{{
#!CommitTicketReference repository=""
revision="00169bc36156d4a32546229bf39de91213709eaf"
Fixed #30547 -- Doc'd how Meta.constraints affect model validation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:6>

Django

unread,
Jun 20, 2019, 4:46:11 AM6/20/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed
Keywords: constraints, | Triage Stage: Ready for
UniqueConstraint | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"c3a0f76d11f8cb282798770152c875ba49445481" c3a0f76d]:
{{{
#!CommitTicketReference repository=""
revision="c3a0f76d11f8cb282798770152c875ba49445481"
[2.2.x] Fixed #30547 -- Doc'd how Meta.constraints affect model
validation.

Backport of 00169bc36156d4a32546229bf39de91213709eaf from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:7>

Django

unread,
Jul 17, 2019, 11:49:50 PM7/17/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed
Keywords: constraints, | Triage Stage: Ready for
UniqueConstraint | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kevin Christopher Henry):

* cc: Kevin Christopher Henry (added)


Comment:

I suggest that the note be expanded to indicate that uniqueness validation
does ''not'' work if the `condition` parameter is used (i.e. for partial
unique indexes). Based on
[https://github.com/django/django/pull/10796#discussion_r244216763 this
comment] it appears to be a hard problem, and unlikely to be implemented
any time soon.

--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:8>

Django

unread,
Jul 18, 2019, 1:59:03 AM7/18/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed
Keywords: constraints, | Triage Stage: Ready for
UniqueConstraint | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by felixxm):

Good catch! I added clarification in
[https://github.com/django/django/pull/11574 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:9>

Django

unread,
Jul 18, 2019, 6:57:26 AM7/18/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed
Keywords: constraints, | Triage Stage: Ready for
UniqueConstraint | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"230d75f59c43b9731465c4ec92ad714e301637b8" 230d75f5]:
{{{
#!CommitTicketReference repository=""
revision="230d75f59c43b9731465c4ec92ad714e301637b8"
Refs #30547 -- Clarified that partial UniqueConstraints don't affect model
validation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:10>

Django

unread,
Jul 18, 2019, 6:57:53 AM7/18/19
to django-...@googlegroups.com
#30547: Document what happens during model validation with Meta.constraints.
-------------------------------------+-------------------------------------
Reporter: Dirk Groten | Owner: Swatantra
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed
Keywords: constraints, | Triage Stage: Ready for
UniqueConstraint | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"0088e592922e2a711815cdb90a2610a1f1704a9a" 0088e592]:
{{{
#!CommitTicketReference repository=""
revision="0088e592922e2a711815cdb90a2610a1f1704a9a"
[2.2.x] Refs #30547 -- Clarified that partial UniqueConstraints don't
affect model validation.

Backport of 230d75f59c43b9731465c4ec92ad714e301637b8 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30547#comment:11>

Reply all
Reply to author
Forward
0 new messages