Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31440 closed New feature (wontfix)

Add a standard way to set deferrable constraints.

Reported by: Ian Foote Owned by: Ian Foote
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: constraints
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ian Foote)

The behaviour of deferrable constraints (e.g. Foreign Key, Unique) in a transaction can be modified using the SET CONSTRAINTS sql syntax (https://www.postgresql.org/docs/12/sql-set-constraints.html). Supporting this directly in Django will allow extra control over when IntegrityError is raised.

Related to #20581.

Change History (5)

comment:1 by Ian Foote, 4 years ago

Description: modified (diff)

comment:2 by Andy Robles, 4 years ago

Owner: changed from nobody to Andy Robles
Status: newassigned

comment:3 by Mariusz Felisiak, 4 years ago

Owner: changed from Andy Robles to Ian Foote

Andy, this ticket is not accepted. Moreover it looks that Ian already has a patch.

comment:4 by Mariusz Felisiak, 4 years ago

Resolution: wontfix
Status: assignedclosed
Summary: Add a standard way to set deferrable constraintsAdd a standard way to set deferrable constraints.

Thanks for this ticket, however you don't need to use a SET CONSTRAINTS statements in most of transactions, usage is so niche that IMO it's acceptable to force users to call cursor.execute('SET CONSTRAINTS ...') if they really need to. It's just not worth to maintain this hook. You can of course start a discussion on DevelopersMailingList if you don't agree.

comment:5 by Ian Foote, 4 years ago

I think this could be worth including, but I don't feel strongly enough about it right now.

Andy, sorry I didn't mention my previous work on this (see https://github.com/django/django/pull/10338#discussion_r276243141). If this ticket had been accepted, I'd have been happy for you to pick it up and finish it.

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