yiisoft / yiisoft/data-cycle

Allow sort to accept expressions

Open
#57 3 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.