[Django] #30062: Add UniqueConstraint condition parameter

13 views
Skip to first unread message

Django

unread,
Dec 26, 2018, 8:51:46 AM12/26/18
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel | Owner: nobody
Tyslacki |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
According [https://code.djangoproject.com/ticket/29641] and
[https://code.djangoproject.com/ticket/29547] add support of conditional
unique constraint.

Postgresql and sqlite support it as unique index: `CREATE UNIQUE INDEX ...
WHERE condition`, for unsupported databases this constraint will not be
applied at all.

`unique_together` can be marked as deprecated in future as
`index_together` is.

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

Django

unread,
Dec 26, 2018, 10:06:51 AM12/26/18
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel Tyslacki | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


Old description:

> According [https://code.djangoproject.com/ticket/29641] and
> [https://code.djangoproject.com/ticket/29547] add support of conditional
> unique constraint.
>
> Postgresql and sqlite support it as unique index: `CREATE UNIQUE INDEX
> ... WHERE condition`, for unsupported databases this constraint will not
> be applied at all.
>
> `unique_together` can be marked as deprecated in future as
> `index_together` is.

New description:

According [https://code.djangoproject.com/ticket/29641] and
[https://code.djangoproject.com/ticket/29547] add support of conditional
unique constraint.

Postgresql and sqlite support it as unique index: `CREATE UNIQUE INDEX ...
WHERE condition`, for unsupported databases this constraint will not be
applied at all.

--

Comment:

I don't think deprecating `index_together` is currently planned but
[https://docs.djangoproject.com/en/2.1/ref/models/options/#index-together
the documentation do suggest it might be in the future].

I adjusted the ticket description and created #30063 so this ticket can
focus on `UniqueConstraint(condition)`.

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

Django

unread,
Dec 27, 2018, 11:10:01 AM12/27/18
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel Tyslacki | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* has_patch: 1 => 0


Old description:

> According [https://code.djangoproject.com/ticket/29641] and
> [https://code.djangoproject.com/ticket/29547] add support of conditional
> unique constraint.
>
> Postgresql and sqlite support it as unique index: `CREATE UNIQUE INDEX
> ... WHERE condition`, for unsupported databases this constraint will not
> be applied at all.

New description:

According #29641 and #29547, add support of conditional unique constraint.

Postgresql and sqlite support it as unique index: `CREATE UNIQUE INDEX ...
WHERE condition`, for unsupported databases this constraint will not be
applied at all.

--

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

Django

unread,
Dec 27, 2018, 3:24:59 PM12/27/18
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel Tyslacki | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


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

Django

unread,
Jan 9, 2019, 10:38:32 AM1/9/19
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel Tyslacki | Owner: Pavel
| Tyslacki
Type: New feature | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* status: new => assigned
* needs_better_patch: 1 => 0
* owner: nobody => Pavel Tyslacki


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

Django

unread,
Jan 12, 2019, 10:32:47 AM1/12/19
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel Tyslacki | Owner: Pavel
| Tyslacki
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"b69f8eb04cc8762d3dfd5af5ea1fc58e3f2ebcc3" b69f8eb0]:
{{{
#!CommitTicketReference repository=""
revision="b69f8eb04cc8762d3dfd5af5ea1fc58e3f2ebcc3"
Fixed #30062 -- Added support for unique conditional constraints.
}}}

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

Django

unread,
May 20, 2019, 4:54:15 AM5/20/19
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel Tyslacki | Owner: Pavel
| Tyslacki
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

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

In [changeset:"5402061c80aa2ede08a7c6b3ff204646c5059cf7" 5402061c]:
{{{
#!CommitTicketReference repository=""
revision="5402061c80aa2ede08a7c6b3ff204646c5059cf7"
Refs #30062 -- Corrected UniqueConstraint signature in docs.
}}}

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

Django

unread,
May 20, 2019, 4:55:10 AM5/20/19
to django-...@googlegroups.com
#30062: Add UniqueConstraint condition parameter
-------------------------------------+-------------------------------------
Reporter: Pavel Tyslacki | Owner: Pavel
| Tyslacki
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

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

In [changeset:"83605a17f07e533c40e5a5367d99148bd98866b8" 83605a17]:
{{{
#!CommitTicketReference repository=""
revision="83605a17f07e533c40e5a5367d99148bd98866b8"
[2.2.x] Refs #30062 -- Corrected UniqueConstraint signature in docs.

Backport of 5402061c80aa2ede08a7c6b3ff204646c5059cf7 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages