-
-
Notifications
You must be signed in to change notification settings - Fork 889
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
Strange Behavior of the Method useFetchJoinCollection in PaginationExtension #965
Comments
Please see the Doctrine issue linked in the PHPDoc: doctrine/orm#2910 By the way, |
In any case, it'd be great if you can add a failing test case. |
@teohhanhui : Thanks for the answer. Are we supposed to put fetchJoinCollection to TRUE even my Request is a Simple SELECT without JOIN ? |
@sroze , any idea ? :-) |
Hi @jordscream, thanks for finding and reporting this issue. Has you seem to have found a fix, do you see you can provide a PR (targetting the 2.0 branch)? Or at least a failing test to allow us to fix this? |
@jordscream:
Yes, that is the default. Please open an issue on https://github.com/doctrine/doctrine2 if you've found a bug with the Doctrine Paginator. |
After investigation: MySQL 5.7 and postgresql x.x: (https://www.postgresql.org/docs/9.3/static/queries-limit.html) When you create a request with limit/offset or distinct without an ORDER clause, the request will give inconsistent results. The only solution is to put a default order in your request. |
Thanks for the report. Is it possible to patch Doctrine directly to fix this? Or at least API Platform? |
Thought we already had an ORDER clause by default, if not we can just add one. |
@soyuka @dunglas , Thanks for your response. As suggest @soyuka , we can effectively add a default order in API platform. The question is:
What do you think ? Thanks |
Indeed, I'd put this in the PaginationExtension. |
@jordscream Yes as it's a bug fix you can PR on 2.0 :) |
Hmm okay I remembered correctly then, why isn't it being called in this use
case? Maybe just a wrong priority in extensions?
…On Thu, 9 Mar 2017 at 10:35, Teoh Han Hui ***@***.***> wrote:
We already have
https://github.com/api-platform/core/blob/master/src/Bridge/Doctrine/Orm/Extension/OrderExtension.php
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#965 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQr87Ga_J5FavO9daTPjcv2ZNpY12msks5rj8fJgaJpZM4MSA8k>
.
|
No, because the default is null. This should be a no-op because it's a Doctrine bug when using a newer version of MySQL (more standards-compliant). |
@teohhanhui , @soyuka Good Point, OrderExtension seems right. With the setting of parameter %api_platform.collection.order% to DESC or ASC for example, it applies a default order in ClassMetadata identifier. Question is : Can we put this parameter to a default value (DESC for example) ? |
Okay, that makes sense since the Doctrine Paginator bug should affect all standards-compliant DBMS. |
Hello,
I was doing tests with pagination in API platform.
The pagination FAILED for me. In several pages during my pager navigation, it displays sometimes an object already proposed in a previous page.
I tried to investigate the problem and apparently, it seems to come from the method useFetchJoinCollection developed in the class PaginationExtension.
This method, in a simple entity to paginate return true, even for a simple entity (no relation with another entity).
The result is that Doctrine apply a TreeWalker to DISTINCT the data and apply a LIMIT and OFFSET.
More, I do not understand the logic function
private function useFetchJoinCollection(QueryBuilder $queryBuilder): bool { return !QueryChecker::hasRootEntityWithCompositeIdentifier($queryBuilder, $this->managerRegistry); }
If the entity has a composite identifier, beacause of the "!", it returns false. Why Did you put a "!" ?
If I delete the "!" operator, it works, cause my Entity does not need to fetchJoinCollection.
Any suggestion?
The text was updated successfully, but these errors were encountered: