-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Undefined index: isIdentifier in Hydrator #9483
Comments
This comment was marked as spam.
This comment was marked as spam.
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. |
@lcobucci @ostrolucky maybe you will have some idea of what to do? |
I'm on mobile now and won't be able to do this but essentially we need to debug what's generated by
|
From what I see when executing the failing test case, it ends up here: orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php Lines 570 to 575 in bfed8cb
I'm not sure what to add there, but when I add
'dqlAlias' => '' in the listing above.
|
I have some time today for checking it 👍 |
@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? |
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 The unintended result highlighted here is that Using scalar hydrators work just fine: <?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\Tests\OrmFunctionalTestCase;
final class GH9483Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->setUpEntitySchema(
[
GH9483SomeEntity::class,
]
);
}
public function testLimitSubqueryWalkerIsIdentifierUndefined(): void
{
$this->_em->persist(new GH9483SomeEntity());
$this->_em->flush();
$dql = 'SELECT e FROM Doctrine\Tests\ORM\Functional\Ticket\GH9483SomeEntity e';
$query = $this->_em->createQuery($dql);
$query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_TREE_WALKERS, [\Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker::class]);
self::assertSame([['__dctrn_id' => 1]], $query->getResult(AbstractQuery::HYDRATE_SCALAR));
self::assertSame(1, $query->getResult(AbstractQuery::HYDRATE_SINGLE_SCALAR));
}
}
/** @Entity */
final class GH9483SomeEntity
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
public $id;
} 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 |
Summary
After merge #7905 (doctrine/orm > 2.6.4) i'm having problems with LimitSubqueryWalker and AbstractHydrator. When i add hint
LimitSubqueryWalker
to Query and try to hydrate my Query i will get NoticeUndefined index: isIdentifier
in lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:459How to reproduce
For reproduce i wrote test:
The text was updated successfully, but these errors were encountered: