Opened 6 years ago

Closed 5 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 by Mads Jensen, 6 years ago

Description: modified (diff)

comment:2 by Simon Charette, 6 years ago

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

comment:3 by Tim Graham, 6 years ago

Summary: Exclude using constraintAdd support for EXCLUDE USING constraint

comment:4 by Mads Jensen, 5 years ago

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 by Mariusz Felisiak, 5 years ago

Patch needs improvement: set

comment:6 by Mads Jensen, 5 years ago

Patch needs improvement: unset

comment:7 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 7174cf0:

Refs #29824 -- Added RangeOperators helper class.

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

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