Allow sort to accept expressions
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 9
- Forks
- 3
- Avg merge
- 1h 6m
- Merged PRs (30d)
- 1
Description
Proposed new feature or change
I'm trying to sort a column by custom sort order via expression.
$expression = "FIELD(country_code, '" . $fields . "')");
return Sort::only([
'country_code' => [
'asc' => [$expression => SORT_ASC],
'desc' => [$expression => SORT_DESC],
],
]);
But \Yiisoft\Data\Reader\Sort::only() does not accept expression.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Yiisoft\Data\Reader\Sort::only() and trace how sort fields and directions are validated and converted. Confirm how an expression such as FIELD(country_code, ...) can be accepted for ascending and descending order, then add or update coverage for the custom sort ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100