Skip to content
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::toIterable() should support mixed result queries with scalar mappings #8555

Closed
wants to merge 5 commits into from

Conversation

alex-dev
Copy link

Fix #8520 and supersedes #8467.

AbstractHydrator::toIterable reuses AbstractHydrator::iterate which had as only problem , as far as I know, weirdly normalized data. The real cause here is AbstractHydrator::hydrateRow, but since it is not internal, it could not be fixed. Therefore, AbstractHydrator::toIterable normalizes rows returned by AbstractHydrator::iterate.

@alex-dev
Copy link
Author

alex-dev commented Mar 23, 2021

Ok. What the f**k. I get several failed tests that don't even consume my changeset.

Case in point: Doctrine\Tests\ORM\Functional\QueryTest::testToIterableWithMultipleSelectElements fails. Fair enough.
Debug some and I dump the output of a Query::getResult() call. I have not touched any ::getResult() code path.
So I look at the dump...

array(3) {
  [0] => class Doctrine\Tests\Models\CMS\CmsArticle#12754 (6) {
    ...
    public $user => class Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser#12782 (15) {...}
    ...
  }
  [1] => class Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser#12782 (15) {...}
  [2] => class Doctrine\Tests\Models\CMS\CmsArticle#12783 (6) {
    ...
    public $user => class Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser#12782 (15) {...}
    ...
  }
}

Check the DQL... It seems legit: select a, u from ' . CmsArticle::class . ' a JOIN ' . CmsUser::class . ' u WITH a.user = u.
I'd expect

array(3) {
  [0] => class Doctrine\Tests\Models\CMS\CmsArticle#12754 (6) {
    ...
    public $user => class Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser#12782 (15) {...}
    ...
  }
  [1] => class Doctrine\Tests\Models\CMS\CmsArticle#12783 (6) {
    ...
    public $user => class Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser#12782 (15) {...}
    ...
  }
}

Reset to 2.8.x and test passes. Re-add my dump. Same unexpected output .

Anyone got an idea?

@alex-dev alex-dev changed the title Fix 8520 Query::toIterable() should support mixed result queries with scalar mappings Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query::toIterable() should support mixed result queries with scalar mappings
2 participants