mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Cascade remove tries to delete child entities with wrong colum name for fk column #5452
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 @Vassyli on GitHub (Mar 11, 2017).
During testing our entities, I've found that a OneToMany relationship with
cascade={"persist", "remove"}successfully persists child entities, but fails to remove them with a DBALException.Parent Entity:
Child Entity:
Removal of the parent entity results in an exception:
The issue lies in the naming of the fk column: Doctrine tries to use the colum name "scene", which does not exist in the table. Instead, the column is actually called scene_id as specified in
@JoinColumn. Removal of the@JoinColumndoes not change the result (it still throws the exception).Renaming the join column to "scene" circumvents this issue. We use currently the most recent version (2.5.6) on PHP 7.1.
@Ocramius commented on GitHub (Mar 12, 2017):
@Vassyli got a trace?
@Vassyli commented on GitHub (Mar 12, 2017):
Sure:
Deletor.php looks like
@Vassyli commented on GitHub (Apr 2, 2019):
This issue is still up with additional problems. I have an entity with the following foreign key as the sole primary key:
Again, inserting new entities seems to work without any issue, but if we delete them, doctrine uses "owner" instead of "owner_id". This still is true in Doctrine 2.6, and renaming the column does not seem to help. The complete class_info of that entity looks like that:
@Vassyli commented on GitHub (Apr 2, 2019):
I just leave this here: This seems to be a sole issue with AnsiQuoteStrategy. Switching to BasicQuoteStrategy prevents this problem.