Opened 3 months ago

Last modified 3 months ago

#31583 new New feature

Extend deferred unique constraint support to OneToOneField

Reported by: BorisZZZ Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: DEFERRED
Cc: Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Support for DEFERRABLE INITIALLY DEFERRED was added in https://code.djangoproject.com/ticket/20581 . It would be great if it could be extended to the implicit Unique constraint generated by OneToOneField, say, by adding an argument:
OneToOneField(OtherModel, defer=models.Deferrable.DEFERRED)

Change History (1)

comment:1 Changed 3 months ago by Simon Charette

Triage Stage: UnreviewedSomeday/Maybe

Not sure we should do that as it seems pretty niche.

I guess an alternative API could be to allow passing a UniqueConstraint to the unique kwarg like we've discussed doing to the Field.index one.

e.g.

OneToOneField(OtherModel, unique=UniqueConstraint(defer=models.Deferrable.DEFERRED))
Note: See TracTickets for help on using tickets.
Back to Top