Do not use batch loading for collections with composite identifier#11289
Merged
greg0ire merged 6 commits intodoctrine:2.19.xfrom Mar 18, 2024
Merged
Conversation
After 2.17 (some?) EAGER fetched OneToMany associations stopped working, if they have multiple join columns. Loads for these associations will trigger a `MessingPositionalParameter` exception "Positional parameter at index 1 does not have a bound value". This test case should reproduce this issue, so it can be fixed.
beberlei
previously approved these changes
Mar 16, 2024
Member
beberlei
left a comment
There was a problem hiding this comment.
Bug is valid, introduced a fix and updated the PR title and description with details.
beberlei
previously approved these changes
Mar 16, 2024
greg0ire
approved these changes
Mar 18, 2024
Member
greg0ire
pushed a commit
that referenced
this pull request
Nov 18, 2025
I think #11289 did not completely fix problem for eager fetch. Change in that PR checked if primary key of target class is composite but that does not matter when loading collection by foreign key. It should check if foreign key on target class is composite. Fix from that PR did not work for me because i had entity with regular autogenerated id (single column), but foreign key referenced entity with composite primary key, like SecondLevelWithoutCompositePrimaryKey in this PR. Checking if foreign key is composite fixed the problem for me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In 2.17 EAGER fetched OneToMany associations stopped working, if they have multiple join columns due to #8391.
Loads for these associations will trigger a
MessingPositionalParameterexception "Positional parameter at index 1 does not have a bound value".This test case should reproduce this issue (#11154), so it can be fixed.
The PR changes eager loading for target associations with composite identifier not to use batch loading anymore, falling back to the original behavior before #8391. It also cleans up the conditions here after they were made more complex than necessary with #11082
Related:
Fixes #11154