[9.x] Cursor pagination: convert original column to expression #41003
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Imagine you write the following query:
According to the documentation, this should work:
But this query will only work when fetching the first page. When you fetch the users of the second page / next cursor, you will get the following error:
This is caused by the fact that the raw output of the
getOriginalColumnNameForCursorPagination
method is provided to awhere
method. This means that the original column value is interpreted as a real column name. That is not the case when aliasing a dynamic column.By wrapping the result of the
getOriginalColumnNameForCursorPagination
method in an\Illuminate\Database\Query\Expression
object, we ensure that the original column value is correctly interpreted.