Delete Propagation to Parent Table for Joined Table Inheritance #11136
Labels
awaiting info
waiting for the submitter to give more information
use case
not really a feature or a bug; can be support for new DB features or user use cases not anticipated
Describe the use case
When a polymorphic table is created via joined table inheritance, I would expect that deleting a row in the subclass table would also delete the row in the parent table. I've found that when the subclass row is explicitly deleted, the delete propgates to the parent table as I would expect. However when the subclass row is deleted via cascading delete, that deletion doesn't propagate to the parent table. This leaves us in an undesirable state with several orphaned rows in the parent table. The only clear way of handling this I've found is to use event listeners in place of a proper cascading delete but ideally there should be a way to handle this so that cascading deletes are properly carried through to the parent table.
Databases / Backends / Drivers targeted
Postgresql / psycopg
Example Use
To give an example, imagine there are three tables:
When a row in the engineer table is explicitly deleted, the related row in the Employee table is deleted successfully
When a row in the company table is deleted, the related row in the Engineer table is deleted but that deletion doesn't propagate to the Employee table and this is what I would like to be addressed
Additional context
We're using sqlalchemy version 1.4.31
The text was updated successfully, but these errors were encountered: