mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3169: ManyToMany association fails when joining on a single column of a composity key #3927
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 @doctrinebot on GitHub (Jun 17, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user bramstroker:
I have two entities with a ManyToMany association between them. The first entity *Campsite* has a composite key (campsiteID, year). The second entity Region has a single key (regionID).
I want to create an association between *Campsite::campsiteID* and Region::regionID. See the entities below.
I run the following code to persist a new one.
This results in a record added to the CampsiteRegion table:
campsiteID : 2014
regionID: 1
This is clearly wrong as the value of the year field is added to the campsiteID column.
While debugging the problem I've found an issue with the method to determine the params in ManyToManyPersister on line 147.
The following code pops the last identifier from the array of identifiers.
In my case:
Which picks 2014 as the value to use.
When I change the code to get the actual column from the array everything works as expected.
I am not 100% sure if this change will have some side effects / edge case I'm not aware of.
For the time being I have fixed the problem bij just reversing the properties in my class, but this is not a real fix of course.