Opened 4 years ago

Closed 4 years ago

#29824 closed New feature (fixed)

Add support for EXCLUDE USING constraint

Reported by: Mads Jensen Owned by: Mads Jensen
Component: contrib.postgres Version: dev
Severity: Normal Keywords: constraints postgres
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mads Jensen)

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.

PR

Change History (9)

comment:1 Changed 4 years ago by Mads Jensen

Description: modified (diff)

comment:2 Changed 4 years ago by Simon Charette

Patch needs improvement: set
Triage Stage: UnreviewedAccepted
Version: 2.1master

comment:3 Changed 4 years ago by Tim Graham

Summary: Exclude using constraintAdd support for EXCLUDE USING constraint

comment:4 Changed 4 years ago by Mads Jensen

Patch needs improvement: unset

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.

comment:5 Changed 4 years ago by Mariusz Felisiak

Patch needs improvement: set

comment:6 Changed 4 years ago by Mads Jensen

Patch needs improvement: unset

comment:7 Changed 4 years ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:8 Changed 4 years ago by Mariusz Felisiak <felisiak.mariusz@…>

In 7174cf0:

Refs #29824 -- Added RangeOperators helper class.

comment:9 Changed 4 years ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In a3417282:

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.mariusz@…>

Note: See TracTickets for help on using tickets.
Back to Top