Description
@haddowg The cursor pagination implementation looks great, but I have a question around the sort order that we need to resolve before I tag - because once I tag, any changes would be breaking.
From the description to #37 -
By default the paginator will add a descending sort by the model key (or provided withKeyName column) to the query to ensure a deterministic order even if no sort is applied. If you know your provided sort/order, or default via global scope etc, is deterministic you can turn this off with
withoutKeySort
.
ThewithAscending
method will now only affect this default key sort. I.e you can reverse the default applied key sort, but if its disabled withwithoutKeySort
this will do nothing.
Question: Should it be descending by default?
When you do this in Eloquent:
$posts = Post::query()->cursorPaginate(5);
You get posts in ascending order, not descending order. It took me be surprise when reviewing the tests as it felt like the default order was the wrong way round.
So the question is, should the order be ascending by default? So that it matches Eloquent, which feels more predictable from a DX perspective. Then use a withDescending()
method if the developer wants to change the default?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status