Opened 13 months ago

Last modified 13 months ago

#34796 closed Bug

Deleting child table does not delete columns in parent table when using multi-table inheritance — at Version 1

Reported by: Stephen Finucane Owned by: nobody
Component: Database layer (models, ORM) Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Stephen Finucane)

I am aware that we don't use database-level cascades (ticket:21961) but I expected this to be implemented by Django in Python, given the docs (https://docs.djangoproject.com/en/4.2/topics/db/models/#multi-table-inheritance) say that the automatically-created OneToOneField on the child model will have on_delete=models.CASCADE.

place_ptr = models.OneToOneField(
    Place,
    on_delete=models.CASCADE,
    parent_link=True,
    primary_key=True,
)

I have a minimal reproducer which can be found at https://github.com/stephenfin/django-bug-34796. In summary though, you simply need to create a table using multi-table inheritance and then delete that table. While the child table will be deleted, the corresponding rows in the parent table will remain.

Change History (1)

comment:1 by Stephen Finucane, 13 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top