mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Undefined index: isIdentifier in Hydrator #6928
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 @fink3l on GitHub (Feb 7, 2022).
Summary
After merge https://github.com/doctrine/orm/pull/7905 (doctrine/orm > 2.6.4) i'm having problems with LimitSubqueryWalker and AbstractHydrator. When i add hint
LimitSubqueryWalkerto Query and try to hydrate my Query i will get NoticeUndefined index: isIdentifierin lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:459How to reproduce
For reproduce i wrote test:
@realkasparov commented on GitHub (Feb 14, 2022):
The same situation!
@greg0ire commented on GitHub (Feb 14, 2022):
You seem to still be using an outdated version because now the line with the issue is 460 (not 459). But when I try your test on 2.11.x, I get the issue, which means recent versions are still affected.
@greg0ire commented on GitHub (Feb 14, 2022):
@lcobucci @ostrolucky maybe you will have some idea of what to do?
@lcobucci commented on GitHub (Feb 14, 2022):
I'm on mobile now and won't be able to do this but essentially we need to debug what's generated by
8f847cb5aa/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php (L521)to understand why that index is missing.@greg0ire commented on GitHub (Feb 14, 2022):
From what I see when executing the failing test case, it ends up here:
bfed8cb6ed/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php (L570-L575)I'm not sure what to add there, but when I add
'isIdentifier' => trueor'isIdentifier' => false(I don't have any idea what I'm doing), I get another error messageException: [PHPUnit\Framework\Error\Warning] Undefined array key ""emanating from8f847cb5aa/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php (L159)(which is consistent with'dqlAlias' => ''in the listing above.@lcobucci commented on GitHub (Feb 15, 2022):
I have some time today for checking it 👍
@lcobucci commented on GitHub (Feb 15, 2022):
@fink3l @realkasparov does the snippet represent a real-life use case or is this only there to reproduce the issue? In other words, why are you having to use that SQL walker?
@lcobucci commented on GitHub (Feb 15, 2022):
Just to give more information here, this SQL walker was designed for the pagination tool (ergo my previous question). Using it outside of its designed use case will create unintended results - SQL AST is manipulated to generate a
SELECT DISTINCT table.id AS _dctrn_id FROM table.The unintended result highlighted here is that
ArrayHydrator(andObjectHydrator) doesn't work when that SQL walker is added to the query. That's because, since the linked issue, we're doing a workaround to avoid BC-breaks and always force DBAL type conversion for pagination queries.Using scalar hydrators work just fine:
The ideal solution would be always performing the DBAL type conversion but that's a BC-break. Then, the workaround that was previously introduced could be removed.
With that said, we must ask: why do you need to rely on a pagination SQL walker for a query that doesn't use the paginator component? Or, wouldn't it be easier for you to make your code explicit and use a DQL like
SELECT DISTINCT e.id FROM Doctrine\Tests\ORM\Functional\Ticket\GH9483SomeEntity e?