Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#15121 closed (duplicate)

ForeignKey cascading deletes fail with Integrity Error when to_field attribute set to field other than primary key

Reported by: ben.kank@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3-beta
Severity: Keywords: to_field, cascade, on_delete
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

ForeignKey cascading delete fails with Integrity Error when to_field argument set to field other than primary key. Setting the on_delete argument doesn't change this behavior either.

For example:

models.ForeignKey(Design, related_name='reports', to_field="uuid", on_delete=models.CASCADE)

Change History (2)

comment:1 Changed 4 years ago by carljm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed
  • Triage Stage changed from Unreviewed to Accepted

This is actually a symptom of #11319. If fixing #11319 turns out to be too difficult to do before 1.3, the deletion code could potentially work around it so deletions don't fail - but that's a last resort. Marking as duplicate.

comment:2 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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