#34796: Deleting child table does not delete columns in parent table when using
multi-table inheritance
-------------------------------------+-------------------------------------
Reporter: Stephen Finucane | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Stephen Finucane:
Old description:
> 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 produced a reproducer which I will provide a link to shortly. 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,
New description:
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34796#comment:1>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018a27f4536b-f055230d-d3da-44c7-859a-a2650c876c4c-000000%40eu-central-1.amazonses.com.