[7.x] Reset select bindings when setting select#32531
Merged
taylorotwell merged 1 commit intolaravel:7.xfrom Apr 24, 2020
sebsel:7.x
Merged
[7.x] Reset select bindings when setting select#32531taylorotwell merged 1 commit intolaravel:7.xfrom sebsel:7.x
taylorotwell merged 1 commit intolaravel:7.xfrom
sebsel:7.x
Conversation
Member
|
@sebsel best that you explain why this is needed (see the pr template) |
Contributor
Author
|
@driesvints I updated the text. Hope this works, because I can't seem to find a PR template. |
Member
|
@sebsel This is visible whenever you open up a new PR: https://raw.githubusercontent.com/laravel/framework/7.x/.github/PULL_REQUEST_TEMPLATE.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.