Opened 13 years ago

Closed 13 years ago

#16119 closed New feature (invalid)

ForeignKey.on_delete emulated only

Reported by: mischiew@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
Severity: Normal Keywords: foreign key, on delete
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The on_delete property of ForeignKey is only emulated by Django, which means it is not implemented as a database definition. This has drawbacks:

  • prevents from using certain modes (especially RESTRICT)
  • makes it dangerous when the database is accessed by another client than Django (why should it be restricted?)

There should be at least an option to remove the emulation and use the normal database support when available (which is the most frequent scenario).

On the same not, on_update would be nice to have.
Likewise for ManyToManyField, support for on_delete and on_update would be nice.

Change History (1)

comment:1 by Karen Tracey, 13 years ago

Resolution: invalid
Status: newclosed

This sounds like a dupe of #7539, which was implemented for 1.3, see: https://docs.djangoproject.com/en/1.3/releases/1.3/#configurable-delete-cascade and https://docs.djangoproject.com/en/1.3/ref/models/fields/#django.db.models.ForeignKey.on_delete

Yet the version here has been set to 1.3, which is a bit confusing. If there is something lacking in the 1.3-implemented support please spell it out more clearly. RESTRICT corresponds to PROTECT in the Django implementation; if you do not want Django to emulate cascade then on the Django side you specify DO_NOTHING and ensure that the DB is set up properly to do the cascade itself.

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