Open Tigrov opened 4 days ago
How to understand which order is default?
Usually it's in ascending order.
Order in Sort
object is field name + order direction, e. g. "id asc". Configuration may contains a lot of fields, how we can understand which field should use by default?
By default sort by all fields in ascending order
For set default order we should select field also, not only direction. How we can understand which field should use by default?
For example, configuration: ['id' => ..., 'name' => ..., 'create_date' => ...]
. Order may be id asc
or create_date asc
or name asc
...
If we use KeysetPaginator
, then sorting is required. In case $currentOrder
is not set, we can use the first field from the configuration. If multiple fields are required for sorting, the user must initialize $currentOrder
.
$currentOrder
can be set to default value after normalizing config.https://github.com/yiisoft/data/blob/15ddd6e3bbb58bc7e341e173b0b66a51936dcecc/src/Reader/Sort.php#L114-L126
This will help avoid an exception if
$currentOrder
is not set manually.https://github.com/yiisoft/data/blob/15ddd6e3bbb58bc7e341e173b0b66a51936dcecc/src/Paginator/KeysetPaginator.php#L444-L446