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

Paginator with useOutputWalkers=false allows query with joins #1583

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

ossinkine
Copy link
Contributor

Subject

I am targeting this branch, because it fixing the issue.

Closes #1582

Changelog

### Fixed
Paginator set useOutputWalkers to false for query with joins

@JustDylan23
Copy link
Contributor

can this also be merged in 3.x
https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/3.x/src/Util/SmartPaginatorFactory.php#L61
this issue has affected this branch too

@ossinkine
Copy link
Contributor Author

@JustDylan23 According to CONTRIBUTING.md#base-branch a base branch for bug fixes should be 4.x

@VincentLanglet VincentLanglet requested a review from a team November 24, 2021 10:29
@JustDylan23
Copy link
Contributor

JustDylan23 commented Nov 24, 2021

Will I receive the fix when my version constraint is set to "^3.1"? (of course after I run composer update) I cannot update to a new major of this bundle. I am not familiar with the git workflow that sonata uses to manage its versions.

@jordisala1991
Copy link
Member

Will I receive the fix when my version constraint is set to "^3.1"? (of course after I run composer update) I cannot update to a new major of this bundle. I am not familiar with the git workflow that sonata uses to manage its versions.

This fix is planned to 4.x version, and it is not merged yet.

@JustDylan23
Copy link
Contributor

JustDylan23 commented Nov 24, 2021

@VincentLanglet if I submit a pull request with the same fix targeting 3.x will it be merged or declined? The new paginator was added on 3.x and I would prefer to have this fixed instead of having to target 3.34.1 inside of my composer.json.

Is 3.x still eligible for bugfixes?

I am on version 3.35.0 of sonata-project/doctrine-orm-admin-bundle
and version 2.7.5 of doctrine/orm

This PR fixes the issue I was having related to an output walker breaking when configuring a query in an admin class and selecting a DTO object
DTO objects as in:

public function createQuery($context = 'list')
{
    $query = parent::createQuery($context);
    $alias = $query->getRootAliases()[0];
    $query
        ->select("NEW AppBundle\DTO\Service(
            $alias.id,
            trans.content,
            supplier.name,
            GROUP_CONCAT(DISTINCT building.name SEPARATOR ', '),
            COUNT(ordr),
            SUM(ordr.totalInc))")

Eventually this output walker was called.
https://github.com/doctrine/orm/blob/146b465ec1f3b18f3ea4d5da6ed24287a741f62f/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L521-L545

This exception would be triggered: throw new RuntimeException('The Paginator does not support Queries which only yield ScalarResults.');

This output walker could not find identifiers since the DTO object does not contain any ORM mapping, or so I concluded.
You should be able to reproduce this if you try selecting with this syntax.

The useOutputWalkers would be called called with false with this pull request and thus resolve my issue.

@jordisala1991
Copy link
Member

@VincentLanglet if I submit a pull request with the same fix targeting 3.x will it be merged or declined? The new paginator was added on 3.x and I would prefer to have this fixed instead of having to target 3.34.1 inside of my composer.json.

Is 3.x still eligible for bugfixes?

I am on version 3.35.0 of sonata-project/doctrine-orm-admin-bundle

and version 2.7.5 of doctrine/orm

This PR fixes the issue I was having related to an output walker breaking when configuring a query in an admin class and selecting a DTO object

DTO objects as in:

public function createQuery($context = 'list')

{

    $query = parent::createQuery($context);

    $alias = $query->getRootAliases()[0];

    $query

        ->select("NEW AppBundle\DTO\Service(

            $alias.id,

            trans.content,

            supplier.name,

            GROUP_CONCAT(DISTINCT building.name SEPARATOR ', '),

            COUNT(ordr),

            SUM(ordr.totalInc))")

Eventually this output walker was called.

https://github.com/doctrine/orm/blob/146b465ec1f3b18f3ea4d5da6ed24287a741f62f/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L521-L545

This exception would be triggered: throw new RuntimeException('The Paginator does not support Queries which only yield ScalarResults.');

This output walker could not find identifiers since the DTO object does not contain any ORM mapping, or so I concluded.

You should be able to reproduce this if you try selecting with this syntax.

The useOutputWalkers would be called called with false with this pull request and thus resolve my issue.

You can backport when it gets merged on 4.x

@VincentLanglet VincentLanglet merged commit 77cd79f into sonata-project:4.x Nov 24, 2021
@VincentLanglet
Copy link
Member

Thanks

@ossinkine
Copy link
Contributor Author

@JustDylan23 actually you can fix a version in your composer.json like "sonata-project/doctrine-orm-admin-bundle": "<3.34", until you didn't update to 4.x, I did the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance degradation with the new Paginator
5 participants