[Django] #29824: Exclude using constraint

21 views
Skip to first unread message

Django

unread,
Oct 4, 2018, 7:00:46 AM10/4/18
to django-...@googlegroups.com
#29824: Exclude using constraint
-------------------------------------+-------------------------------------
Reporter: Mads | Owner: Mads Jensen
Jensen |
Type: New | Status: assigned
feature |
Component: | Version: 2.1
contrib.postgres | Keywords: constraints
Severity: Normal | postgres
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
A lot of work was done to add the check constraint to Django 2.2. On top
of such a constraint, PostgreSQL has an exclusion constraint that works
well on ranges, regardless if they're represented using two fields, or a
single field using a range-type. Essentially, this constraint enforces a
unique constraint for ranges, with a possibility for an additional check.

https://github.com/tbicr/django-pg-zero-downtime-migrations/ uses `ALTER
TABLE %(table)s VALIDATE CONSTRAINT` to restrict how long the table is
locked for writing. I was contemplating to touch this subject in the
patch.

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

Django

unread,
Oct 4, 2018, 7:02:21 AM10/4/18
to django-...@googlegroups.com
#29824: Exclude using constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 2.1
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage:
postgres | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Mads Jensen:

Old description:

> A lot of work was done to add the check constraint to Django 2.2. On top
> of such a constraint, PostgreSQL has an exclusion constraint that works
> well on ranges, regardless if they're represented using two fields, or a
> single field using a range-type. Essentially, this constraint enforces a
> unique constraint for ranges, with a possibility for an additional check.
>
> https://github.com/tbicr/django-pg-zero-downtime-migrations/ uses `ALTER
> TABLE %(table)s VALIDATE CONSTRAINT` to restrict how long the table is
> locked for writing. I was contemplating to touch this subject in the
> patch.

New description:

A lot of work was done to add the check constraint to Django 2.2. On top
of such a constraint, PostgreSQL has an exclusion constraint that works
well on ranges, regardless if they're represented using two fields, or a
single field using a range-type. Essentially, this constraint enforces a
unique constraint for ranges, with a possibility for an additional check.

https://github.com/tbicr/django-pg-zero-downtime-migrations/ uses `ALTER
TABLE %(table)s VALIDATE CONSTRAINT` to restrict how long the table is
locked for writing. I was contemplating to touch this subject in the
patch.

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

--

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

Django

unread,
Oct 4, 2018, 9:35:44 AM10/4/18
to django-...@googlegroups.com
#29824: Exclude using constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage: Accepted
postgres |
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
* version: 2.1 => master
* stage: Unreviewed => Accepted


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

Django

unread,
Oct 30, 2018, 4:11:16 PM10/30/18
to django-...@googlegroups.com
#29824: Add support for EXCLUDE USING constraint

-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage: Accepted
postgres |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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

Django

unread,
May 24, 2019, 11:04:55 AM5/24/19
to django-...@googlegroups.com
#29824: Add support for EXCLUDE USING constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage: Accepted
postgres |
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


Comment:

I believe the PR is now in a state where it merits a review. I'm not sure
if the tests should also include the model with two fields, or if it's
sufficient that it's discussed in the documentation.

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

Django

unread,
Jul 9, 2019, 6:23:12 AM7/9/19
to django-...@googlegroups.com
#29824: Add support for EXCLUDE USING constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage: Accepted
postgres |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


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

Django

unread,
Jul 12, 2019, 8:04:09 AM7/12/19
to django-...@googlegroups.com
#29824: Add support for EXCLUDE USING constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage: Accepted
postgres |
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


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

Django

unread,
Jul 16, 2019, 7:51:38 AM7/16/19
to django-...@googlegroups.com
#29824: Add support for EXCLUDE USING constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage: Ready for
postgres | checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Django

unread,
Jul 16, 2019, 3:08:55 PM7/16/19
to django-...@googlegroups.com
#29824: Add support for EXCLUDE USING constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed

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

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"a3417282ac0464a9a2d1d7685bcfef10feed2597" a3417282]:
{{{
#!CommitTicketReference repository=""
revision="a3417282ac0464a9a2d1d7685bcfef10feed2597"
Fixed #29824 -- Added support for database exclusion constraints on
PostgreSQL.

Thanks to Nick Pope and Mariusz Felisiak for review.

Co-Authored-By: Mariusz Felisiak <felisiak...@gmail.com>
}}}

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

Django

unread,
Jul 16, 2019, 3:08:56 PM7/16/19
to django-...@googlegroups.com
#29824: Add support for EXCLUDE USING constraint
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Mads
| Jensen
Type: New feature | Status: assigned

Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: constraints | Triage Stage: Ready for
postgres | checkin
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:"7174cf0b009711c41e5f76f6c0c68137898716a0" 7174cf0]:
{{{
#!CommitTicketReference repository=""
revision="7174cf0b009711c41e5f76f6c0c68137898716a0"
Refs #29824 -- Added RangeOperators helper class.
}}}

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

Reply all
Reply to author
Forward
0 new messages