-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Query::getResult
and Query::toIterable
results differ when selecting multiple entities.
#9106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query::getResult
and Query::toIterable
results differ when selecting multiple entities.
#9106
Conversation
d1f6331
to
8188907
Compare
@greg0ire ‘Query::toIterable’ and ‘Query::getResult’ are they expected to have different outputs? Seems like yes .. but if No then it seems valid problem!!! |
I don't know, but I've found this note in the docs:
https://www.doctrine-project.org/projects/doctrine-orm/en/2.10/reference/batch-processing.html This use case does not seem to be supported at all. Maybe we should throw in that sort of case. |
@ajgarlag hi, by checking docs, Query::toIterable can be used for bulk operations and Query::getResult is for getting hydrated data.. Also Query::toIterable doesn't support joins .. IMHO functionality is working as expected for both functions. |
I think it might make sense. It would be a BC-break, and for that reason the PR should target 3.0.x. |
There is an exception that is already thrown when the DQL expression includes a fetch-join using a mapped orm/lib/Doctrine/ORM/Query/SqlWalker.php Lines 983 to 987 in 416aa1d
The problem exposed it the tests occur when selecting multiple entities with an arbitrary JOIN, or even without any JOIN. I'll update the test case to select completely unrelated entities. |
8188907
to
164b087
Compare
164b087
to
f982b92
Compare
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
This pull request was closed due to inactivity. |
While working on #9098 I've found this bug so I open this PR with a test for the exposed bug.
For the test in the PR with 4 articles (a), for 1 author (u),
Query::getResult
returns 5 results because it only returns one entity per position, whileQuery::toIterable
returns 4 results because it combines the selected entities.Query::getResult
output is[a1, u, a2, a3, a4]
Query::toIterable
output is[[a1, u], [a2, u], [a3, u], [a4, u]]
I prefer the
Query::toIterable
output, so my questions are:Query::toIterable
to mimic theQuery::getResult
output?Query
with the same output currently produced byQuery::toIterable
?Query::toIterable
andQuery::getResult
can differ when selecting multiple entities?