Skip to content

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

Merged
taylorotwell merged 3 commits into
laravel:9.xfrom
maximepvrt:9.x
Dec 7, 2022
Merged

[9.x] Fix aliasing with cursor pagination#45188
taylorotwell merged 3 commits into
laravel:9.xfrom
maximepvrt:9.x

Conversation

@maximepvrt

Copy link
Copy Markdown
Contributor

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

@taylorotwell

Copy link
Copy Markdown
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

maximepvrt commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

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.

2 participants