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

[9.x] Fix aliasing with cursor pagination #45188

Merged
merged 3 commits into from Dec 7, 2022
Merged

Conversation

maximepvrt
Copy link
Contributor

This fixes an issue if "as" is present in cursor pagination alias for casting a column value.

@taylorotwell
Copy link
Member

Please describe the issue in detail. Mark as ready for review when done please. Thanks!

@taylorotwell taylorotwell marked this pull request as draft December 5, 2022 15:12
@maximepvrt
Copy link
Contributor Author

maximepvrt commented Dec 5, 2022

Currently the getOriginalColumnNameForCursorPagination function finds the first occurrence of "as" of a dynamic column with an alias.
The correct alias is the last "as" found in a column expression.
Use explode function is bad, if multiple "as" are presents, it doesn't cut the dynamic column in 2.

I found this issue using cursorPaginate with a column dynamic expression that get the différence between two dates which I then cast to a float.

@maximepvrt maximepvrt marked this pull request as ready for review December 5, 2022 16:54
@taylorotwell taylorotwell merged commit 38c2126 into laravel:9.x Dec 7, 2022
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