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

[10.x] Binding order is incorrect when using cursor paginate with multiple unions with a where #50810

Conversation

thijsvdanker
Copy link
Contributor

When using cursorPaginate on a query that has multiple unions, the binding order is incorrect.

This happens because:

https://github.com/laravel/framework/blob/11.x/src/Illuminate/Database/Concerns/BuildsQueries.php#L436
adds the bindings for the cursor where to the end of the bindings and not in the position that they should be.

The result is a query that binds the wrong values to the wrong parameters in the query.

Possible solutions I can now think of are:

  1. make the bindings for union a nested array until the bindings are resolved to make the query and add the cursor bindings to the right index
  2. re-order the union bindings after adding the cursor bindings

This PR implements the first solution.

This PR is similar to #50795 but made against 10.x

@taylorotwell
Copy link
Member

I would rather not change the structure of the union bindings - I fear it could be a breaking change.

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

Successfully merging this pull request may close these issues.

None yet

2 participants