[9.x] Cursor pagination: convert original column to expression#41003
Conversation
|
Seems like tests are still failing here. Please fix the failing tests and mark as ready. |
|
Won't this break columns that actually need to be quoted? |
|
Oh I did not know that in certain scenario's the columns need to be quoted 🤔 I changed the logic so it checks if the original column is an expression. It does this by checking if the original column starts with a |
|
To do this I also needed to use the grammar of the builder in the I'm not sure if it is allowed to use the grammar in that place 🤔 |
That logic looks wrong to me. Different sql engines have different rules. |
|
I chose to use that logic because the framework/src/Illuminate/Database/Query/Builder.php Lines 269 to 271 in 3a9d609 |
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
getOriginalColumnNameForCursorPaginationmethod is provided to awheremethod. 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
getOriginalColumnNameForCursorPaginationmethod in an\Illuminate\Database\Query\Expressionobject, we ensure that the original column value is correctly interpreted.