Skip to content

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

This is necessary to allow cursor pagination to add a where binding to
the right union query.
@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.

2 participants