-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[4.0] Query builder has no way to reset query parts once set #6186
Comments
Would introducing a method |
It should and we can do that. But at the same time, it feels like resetting a part of the query is a workaround for poor design on the application side. If the application doesn't need the query results to be ordered, why does it specify the order to begin with? Instead of the current logic as I understand it: $builder->orderBy($order);
if (weNeedCount()) {
$builder->resetOrderBy();
} It should behave like this: if (! weNeedCount()) {
$builder->orderBy($order);
} |
My understanding of the issue is that we're talking about a component that applies pagination to an arbitrary query represented as a It is totally reasonable that the original QB contains the "order by" part and I find it okay to make that part resetable. |
On the application side, I agree wholeheartedly.
Exactly this. In the Symfony ecosystem, there are Pagerfanta and |
I don't mind the missing API being implemented, please feel free to file a pull request. |
Up for a PR, @mbabker? If yes, please target 3.8.x. |
I don't mind either. I can work on a PR, unless @mbabker wants to do it! |
@BenMorel If you beat me to it, then go for it. Otherwise I can get to it at some point over the weekend (got other query issues to sort out for work today 😅 ). |
@derrabus I'm not sure if targeting 3.8.x is a good idea:
Regarding the second point, I don't think implementing these methods will help consumers of the I would suggest to just implement them in 4.0.x, and document the upgrade path from |
Another solution would be to backport the Thoughts, @morozov? |
So let's do that.
Can you elaborate?
I don't think that we need those.
This does not apply to the proposed |
I mean, merging into 4.0.x will require changing the implementation. Not that big of a deal.
Don't paginators need to introspect the
No, only to getters. |
Okay, we have a |
Yes, I think they should have been added in the same PR! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Seeing #6179 land, which deprecates
getQueryPart()
andgetQueryParts()
in the upcoming 3.8 release, alerted me to the PR it is based on (#3836) which removed those methods and their reset counterparts (resetQueryPart()
andresetQueryParts()
) in 4.0. As a side effect of the changes from #3836, it is now no longer possible to remove something from the query builder once it's added in.Example Use Case
In Pagerfanta, there is an adapter for a DBAL query builder which performs a SELECT query against a single table. In this adapter, the Closure which modifies the query builder to change the query to a
SELECT COUNT()...
style query uses the query builder'sresetQueryPart()
method to clear theORDER BY
part from the query. This behavior was introduced as a bug fix to resolve an issue with an incorrect query being created on certain platforms.The text was updated successfully, but these errors were encountered: