Closed isarastov closed 3 months ago
I have the same issue after upgrading doctrine, however in my case there is definitely no duplicated select of the same alias. What's even more interesting, the hydration for the query works good if I change one parameter in it, so it seems to be somehow related to the data.
I was trying to figure out what's wrong, so I inspected the raw results of SQL between non-working and working queries. The only difference, I was able to observe, is that the failing query has only one row in the result, when the successful ones return at least few of them, but no idea if this is related.
EDIT: This PR resolves my problem https://github.com/doctrine/orm/pull/11194
I also tested two cases without the fix - the first one returns 4 rows (for the same Foo) and it works, the other returns 39 rows (again, for the same Foo) and it fails. So this probably has nothing to do with the multiple selects.
https://github.com/doctrine/orm/pull/11194 is merged so this may also be resolved?
BC Break Report
EDIT
11194 seems to resolve this issue.
My original assumption was that it's caused by the alias being selected twice, but this proved wrong. It's more probably caused by something in the result itself (at least this seems to be the case for me and @winiarekk)
Summary
After upgrading to 2.16.0 a query that was selecting the same alias twice started throwing the following exception:
Obviously the query shouldn't select the same alias twice, however this was working until 2.15.5. I was able to identify the change that causes the different behavior as this one. If I add the 4 lines from 2.15.5 instead of the call to
registerManaged
it works but I noticed that the$idHash
is an empty string in this case. I also found this issue that seems related: #10889Previous behavior
The Foo entity was hydrated successfully.
Current behavior
Doctrine\ORM\ORMInvalidArgumentException:
in doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php -> getIdHashByEntity
How to reproduce
I tried to reproduce this in a test case, but with no success. Anyway, here's a simplified version of the code that causes the error: