mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Inheritance does not work properly after "Fix OneToManyPersister::deleteEntityCollection missing discriminator column/value." #7399
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @konrad-czernecki-esky on GitHub (Jul 15, 2024).
Bug Report
Summary
After this fix https://github.com/doctrine/orm/issues/11500, I have a problem with the SINGLE_TABLE inheritance type, because when I set a new collection (in order to replace the previous one) in my one-to-many relation, the data in the old collection is not deleted.
Current behavior
The collection that is being replaced has not been replaced (old data remains + new appears)
How to reproduce
*Pseudocode
Reproduction:
The reason is that the SQL query generated in
\Doctrine\ORM\Persisters\Collection\OneToManyPersister::deleteEntityCollectionhas a null value in the "type" column.DELETE FROM components WHERE page_id = eab311cf-9854-4872-a2c6-73376b7b9936 AND type = nullExpected behavior
Old collection should be deleted and only new data should remain. Before v2.19.6 everything works well.
@gitbugr commented on GitHub (Aug 1, 2024):
The issue is caused by your targetEntity being the abstract Component class...
I think in this scenario, the SQL should be
type IN ('example', 'example_2')to continue to be safe. I'll take a look and push up a PR@konrad-czernecki-esky commented on GitHub (Aug 27, 2024):
@gitbugr Thanks for your contribution, everything works in v2.19.7.