[7.x] Reset select bindings when setting select #32531
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #32526
This PR resets the select bindings when the select clause is set to something else.
Most operations on the Query Builder are additive: when you have an instance of it, and you call
->where('column', 'value')
on it, the clause is added to the underlying query.This also works with sub-queries: bindings are merged into the query. Take for example this
orderBy()
:Setting a select query, however, overwrites previous selects. (Use
addSelect()
when you want to add.)When using a subquery in the select clause, registered bindings would currently stay in the query. MySQL 8.0 seems to be fine with that, but Postgres gives an error when this happens.
This PR fixes that by setting the bindings for the select part of the queries to an empty array when an overwriting
->select()
call is made.