#23076: Cascaded deletion of polymorphic models fails
-------------------------------------+-------------------------------------
     Reporter:  jernej@…             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by jmurty):

 * status:  closed => new
 * resolution:  wontfix =>


Comment:

 Please consider re-opening this issue as it is related to Django core's
 handling of proxy models in general, not just django-polymorphic.

 The root cause of this issue is that Django's deletion collector does not
 include M2M reverse references to '''proxy''' parents/ancestors of a model
 when deleting it; it only finds these relationships for '''concrete'''
 parent models. This means that deleting a proxy-based model object with
 extant M2M relationships targeting a proxy parent will fail with integrity
 errors, if you are using a database like PostgreSQL that enforces foreign
 key constraints.

 I have created a Pull Requests based on the current 1.7.x branch that adds
 unit tests demonstrating the issue when run against PostgreSQL:
 https://github.com/django/django/pull/5399

 The same issue affects 1.8, and I can follow up with a PR for that branch
 if it would be useful?

 We have done some work investigating this issue and have the rough
 beginnings of patches for the 1.7 and 1.8 branches, using a different
 approach to the patches earlier in this ticket – namely, adjusting the
 `get_deleted_objects` and related code path to find reverse M2M
 relationships on proxy models.

 We could proceed with these patches, but only if the issue is considered
 relevant and serious enough to fix in Django core.

--
Ticket URL: <https://code.djangoproject.com/ticket/23076#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.efd2548808af8615c7dcdc8b189e303f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to