Cursor pagination add orderBy condition lead to error with old cursor
In the beginning, I'm using orderByDesc("id")->cursorPaginate(10) to create pagination, but after that i need to sort by another field (for example: score, this field is not unique) so i change query like: orderByDesc("score")->orderByDesc("id")->cursorPaginate(10).
It work fine if client is new, but with exist client, their cursor parameter has only id so laravel throw an UnexpectedValueException exception (because it's missing the last score value): github.com/illuminate/pagination/blob/master/Cursor.php#L47.
How can i change the sort condition on server and make it work with the old client cursor
It requires that the ordering is based on at least one unique column or a combination of columns that are unique. Columns with null values are not supported.
Query expressions in "order by" clauses are supported only if they are aliased and added to the "select" clause as well.
@SilenceBringer yes, for sure, my problem is laravel using cursor to store last order data so when i add another sort (orderBy score) the old cursor doesn't have that (last score value from previous page) and throw an exception