Opened 11 years ago

Last modified 9 months ago

#21295 new New feature

Add on_update support

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: loic@…, emorley@…, Akash Kumar Sen, Giannis Terzopoulos, Ülgen Sarıkavak, Ryan Hiebert Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no
Pull Requests:How to create a pull request

Description

There are cases where on-update cascade support would be useful. Currently Django offers no way to cascade updates.

An experimental patch implementing on_update=models.CASCADE support for foreign keys is available from: https://github.com/akaariai/django/tree/update_cascade. It is based on composite foreign keys branch (https://github.com/akaariai/django/tree/soc2013/composite-fields).

I'll attach a sample project to this ticket. Unpack it, use the above mentioned branch of Django, run syncdb, runserver and try in admin. Note that the country/city names are stored locally in the models, so country name update cascades to cities and from cities to streets.

According to the ticket's flags, the next step(s) to move this issue forward are:

  • To write documentation for the patch, then uncheck "Needs documentation" on the ticket.
  • To improve the patch as described in the pull request review comments or on this ticket, then uncheck "Patch needs improvement".
  • If creating a new pull request, include a link to the pull request in the ticket comment when making that update. The usual format is: [https://github.com/django/django/pull/#### PR].

Change History (10)

by Anssi Kääriäinen, 11 years ago

Attachment: test_composite.tar.gz added

Sample project

comment:1 by Anssi Kääriäinen, 11 years ago

Needs documentation: set
Patch needs improvement: set

comment:2 by loic84, 11 years ago

Cc: loic@… added

Awesome work.

I just had a brief look at the diff, it will need special handling to be compatible with migrations, my patch for #21275 addresses this issue.

comment:3 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Ed Morley, 9 years ago

Cc: emorley@… added

comment:5 by Akash Kumar Sen, 20 months ago

This seems to be a interesting topic to work on, but I am not sure about the ideal behavior of the on_update parameter. Some explanation would be very helpful. Are we talking about something similar to the SQL ON UPDATE clause here?

comment:6 by Akash Kumar Sen, 20 months ago

Cc: Akash Kumar Sen added

comment:7 by Giannis Terzopoulos, 12 months ago

Cc: Giannis Terzopoulos added

comment:8 by Ülgen Sarıkavak, 11 months ago

Cc: Ülgen Sarıkavak added

comment:9 by Ryan Hiebert, 9 months ago

Cc: Ryan Hiebert added
Note: See TracTickets for help on using tickets.
Back to Top