mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
ArrayHydrator doesn't hydrate Many-To-One relations when relation is (part of) the primary key #4999
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 @InterEmotion on GitHub (Feb 2, 2016).
I'm investigating an upgrade from Doctrine 2.4.0 to 2.5.4. For performance reasons array hydration is used in a few cases. This worked fine/as expected in version 2.4.0. Since 2.4.1 it doesn't. It got changed becuse of this issue and commit: DDC-2759
Problem: the ArrayHydrator doesn't hydrate Many-To-One relations when the attribute is (part of) the primary key.
I have done a little digging into this and studied the ResultSetMapping data. I couldn't find anything to query without risking naming collisions. However, the association mapping that gets queried earlier in the hydration contains the conclusive information:
So by expanding the check in
ArrayHydrator.phpfrom:to:
The hydration works again as expected and won't give the regression issues from 2.4.0. I hope you can concur with my findings and solution, and adopt it.
@Jean85 commented on GitHub (Feb 5, 2016):
Have you tried running the tests with this modification?
@InterEmotion commented on GitHub (Jun 17, 2016):
I sincerely apologize for my late reaction. I got pulled into other matters. The issue is still a problem for me though.
I have run the unittests with the modified code (master branch). It produced the following new failure:
@InterEmotion commented on GitHub (Jun 21, 2016):
Again, my apologies. It turned out te be a naming collision. The name of the property was the same as that of the key. In my case, renaming the column to ****_id did the trick.
Can be closed.