mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Unexpected result of an arbitrary join #5964
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 @SenseException on GitHub (May 10, 2018).
Originally assigned to: @SenseException on GitHub.
Bug Report
I'm currently evaluating a few documentation bits and need a confirmation, that this issue is truly a bug.
The arbitrary join described at the bottom of the documentation here shows the possibility to make a join with different columns than the ones used in the associations of entities. While the DQL is working, I don't get the expected result. So the questions are
Summary
While a regular join, that is supposed to hydrate the associated entities without lazy loading, already loads the collection (example is OneToMany), this doesn't seem to be the case for the arbitrary joins. Arbitrary joins still keep the collection in a lazy state. Loading the lazy state will still result loading all relations by the OneToMany configuration.
Current behavior
Currently, the associations in the collection are lazy despite having the relational entity listed in
SELECT. After it gets accessed, the whole associations will be loaded, not the ones of the arbitrary join.With the data and entities of "How to reproduce", one
Fooentity will be returned with all threeBarrelations.How to reproduce
Entities
Data rows of the test
Table bar
Table foo
Expected behavior
The expected behaviour would be that only one
Barentity with thenumber1 is in the result of the one existingFoo.@Ocramius commented on GitHub (May 10, 2018):
@SenseException can you clarify on the Expected behavior vs Actual behavior? I don't understand what the result you are getting looks like. IF you can make an example like
Table foo, that would be best.@SenseException commented on GitHub (May 10, 2018):
I've extended the description with a structure containing the current and expected amount of
Barentities. The result is based on the table rows from "Table foo" and "Table bar". Does this make it more understandable?@Ocramius commented on GitHub (May 10, 2018):
@SenseException I see. The "actual" behavior is correct though, as an arbitrary join has no way to know that you are fetch-joining
f.bars.Instead, I'd expect a result like following (I know it's not like this, but this is what I got off the top of my head):
@SenseException commented on GitHub (May 14, 2018):
Then it's not a bug but missing documentation. I suggest to update the documentation for the arbitrary join:
This would highlight more that DQL isn't some form of SQL like the introduction of DQL mentions in https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/dql-doctrine-query-language.html and makes the arbitrary join more understandable.
@SenseException commented on GitHub (Jun 10, 2018):
I've created a PR for extending the documentation. Please feel free to take a look at it.
@Ocramius commented on GitHub (Jun 11, 2018):
Handled in #7255