mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Manual foreign key constraint definition #5213
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 @ghost on GitHub (Aug 5, 2016).
Originally assigned to: @Ocramius on GitHub.
I have a situation where I need to connect two entities with a shared group key, which is an arbitrary value, which is optional on one of the entities, but not on the other. In a manner of speaking I want to connect EntityB to EntityA, but make sure the group key remains identical in both entities for this connection.
In MySQL this can be achieved with a normal foreign key constraint of the two columns, but in Doctrine this is not possible because the group key is not part of the primary key of EntityA.
Is there some way this could be achieved? If I leave the double column definition in the yaml, then the schema is correct, but the persister breaks. If I remove it, the migrations:diff replaces the constraint in the schema.
Can I somehow add my own manual foreign key constraint definition, so that MySQL has the double constraint, but Doctrine uses this as a single constraint and continues to work?
Thanks in advance
@SenseException commented on GitHub (May 10, 2018):
If this is about an arbitrary join like it is described at the bottom of https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#dql-select-examples, this issue can be closed.
@Ocramius commented on GitHub (Aug 23, 2018):
Closing as per @SenseException's comment.