Closed mpdude closed 2 years ago
(OTOH, I'm a bit unsure if the approach is sane... Can the
Child
Entity Manager not know aboutParent
? If it needs to know that class, the way the ORMPurger works would be to include that table as well, since the ORMPurge purges all tables managed by a given EntityManager?)
If an entity extends another one, the EntityManager cannot known only the child class. That's not a supported usage of doctrine/orm (and would probably require weird hacks to even attempt doing that)
Yeah, I became aware of that as I wrote the above description and wondered what I was doing…
Given that the ORMPurger is designed to purge all entity classes in a given EntityManager, and that the EM cannot manage an entity class that inherits from another one without also knowing that parent class (as stof explained above), the current behavior makes sense.
Thank you for the clarification.
Assume the following class hierarchy:
Both entities have their own, completely unrelated database tables.
I think it is ok (at least, I have a project where it seems to work) to have two different Entity Managers configured, and the first one knows only about the
Parent
, the other about theChild
entity.When using the
ORMPurger
with the EntityManager for classChild
, it should not try to truncate/delete theparent
table. This is what this PR tries to do – do not include another table when we're not dependent on it, when there is no inheritance mapping relationship.(OTOH, I'm a bit unsure if the approach is sane... Can the
Child
Entity Manager not know aboutParent
? If it needs to know that class, the way the ORMPurger works would be to include that table as well, since the ORMPurge purges all tables managed by a given EntityManager?)