Consider usage of setFetchMode when checking for simultaneous usage of fetch-mode EAGER and WITH condition#11174
Closed
Abbraxar wants to merge 1 commit intodoctrine:2.17.xfrom
Closed
Conversation
…f fetch-mode EAGER and WITH condition. This fixes a bug that arises when an entity relation is mapped with fetch-mode EAGER but setFetchMode LAZY (or anything that is not EAGER) has been used on the query. If the query use WITH condition, an exception is incorrectly raised (Associations with fetch-mode=EAGER may not be using WITH conditions). Fixes doctrine#11128
Contributor
|
Is this to be considered? It may solve a BC introduced in #8391 |
beberlei
requested changes
Apr 27, 2024
Member
beberlei
left a comment
There was a problem hiding this comment.
Thanks for this PR, this is indeed an oversight and the fix looks good.
I have two improvements for the PR.
| use Doctrine\ORM\Query; | ||
| use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
|
||
| class GH11128Test extends OrmFunctionalTestCase |
Member
There was a problem hiding this comment.
Instead of adding a new test-case and model, you can just add another test to the existing by adapting for example EagerFetchCollectionTest::testSubselectFetchJoinWithNotAllowed
| } | ||
|
|
||
| if ($relation['fetch'] === ClassMetadata::FETCH_EAGER && $condExpr !== null) { | ||
| if (($this->query->getHint('fetchMode')[$assoc['sourceEntity']][$assoc['fieldName']] ?? $relation['fetch']) === ClassMetadata::FETCH_EAGER && $condExpr !== null) { |
Member
There was a problem hiding this comment.
Suggested change
| if (($this->query->getHint('fetchMode')[$assoc['sourceEntity']][$assoc['fieldName']] ?? $relation['fetch']) === ClassMetadata::FETCH_EAGER && $condExpr !== null) { | |
| $fetchMode = $this->query->getHint('fetchMode')[$assoc['sourceEntity']][$assoc['fieldName']] ?? $relation['fetch']; | |
| if ($fetchMode === ClassMetadata::FETCH_EAGER && $condExpr !== null) { |
Contributor
|
@Abbraxar would appreciate if you could finish this PR. If you don't have time I could do it! |
Author
|
Hi @aprat84 ! |
Contributor
|
Can't edit this PR, so cloned it: #11445. |
Author
|
Closing this PR, go see #11445 |
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.
Concern issue #11128