Skip to content

Eloquent cursor pagination doesn't apply global scopes correctly with unions #55751

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

Draft
wants to merge 1 commit into
base: 12.x
Choose a base branch
from

Conversation

thijsvdanker
Copy link
Contributor

When using:

  • Eloquent builder
  • cursor pagination
  • unions on models that have global scopes

the global scopes are not applied correctly to the union queries, resulting in to little columns in the resulting query.
This causes either an error from the database that the number of columns / bindings have a mismatch (SQLite) or the bindings are applied to the wrong columns (SQL Server).

When using toBase() on the union query this issue goes away.
I don't know what the right moment would be to applyScopes on the union query so don't know how to work on a fix for this issue.

@thijsvdanker thijsvdanker force-pushed the fix-eloquent-union-cursor-pagination-with-global-scopes branch from d1d764e to ad7bd37 Compare May 16, 2025 11:59
@taylorotwell taylorotwell marked this pull request as draft May 16, 2025 14:22
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.

1 participant