Add sort direction constants

Created on 17 February 2020, almost 5 years ago
Updated 2 February 2023, almost 2 years ago

Problem/Motivation

There are sort direction constants in the class TableSort


# core/lib/Drupal/Core/Utility/TableSort.php

class TableSort {

  const ASC = 'asc';
  const DESC = 'desc';

For me, would be great if they are generic ones. For example:

  • Sort::ASC
  • Sort::DESC

Then, while writing entity queries, do not need to worry about misspelling them, especially, for non-English speakers.

$query->sort('fieldname', Sort::ASC);

Proposed resolution

Add sort direction constants to \Drupal\Core\Entity\Query\QueryInterface as per suggestion form @longwave #2

Remaining tasks

Needs review

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
DatabaseΒ  β†’

Last updated 2 days ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡¨πŸ‡³China jungle Chongqing, China

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Seems like a helpful constant.

    Think including a simple query showing them working would be useful.

Production build 0.71.5 2024