Sorting nodes by title aren't returned in correct order.

Created on 6 December 2020, over 3 years ago
Updated 19 March 2024, 3 months ago

Problem/Motivation

I've been playing around this the JSON:API module in D9 using the Umami Profile to have some content to query against. I noticed that when sorting by title on node queries they are not being returned in the correct alphabetical order (at least as I understand it).

For instance: /jsonapi/node/recipe?sort=title returns the list of recipes in the following order:

  1. Vegan chocolate and nut brownies
  2. Crema catalana
  3. Thai green curry
  4. Deep mediterranean quiche
  5. Fiery chili sauce
  6. Gluten free pizza
  7. Super easy vegetarian pasta bake
  8. Victoria sponge cake
  9. Watercress soup


Actually the reverse order is off as well. "Deep mediterranean quiche" should be above "Crema catalana" and "Gluten free pizza" should be above "Fiery chili sauce"

  1. Watercress soup
  2. Victoria sponge cake
  3. Vegan chocolate and nut brownies
  4. Thai green curry
  5. Super easy vegetarian pasta bake
  6. Fiery chili sauce
  7. Deep mediterranean quiche
  8. Gluten free pizza
  9. Crema catalana

the same thing appears to be happening on other content types such as articles: /jsonapi/node/article?sort=title

I'm using Umami as an example but I assume there is nothing particular about the Umami profile that is causing the issue.

Steps to reproduce

  1. Install Drupal 9 with the Umami Profile.
  2. Enable the JSON:API module and any associated modules.
  3. Got to the url: /jsonapi/node/recipe?sort=title

Expected Order:

  1. Crema catalana
  2. Deep mediterranean quiche
  3. Fiery chili sauce
  4. Gluten free pizza
  5. Super easy vegetarian pasta bake
  6. Thai green curry
  7. Vegan chocolate and nut brownies
  8. Victoria sponge cake
  9. Watercress soup

Actual Order:

  1. Vegan chocolate and nut brownies
  2. Crema catalana
  3. Thai green curry
  4. Deep mediterranean quiche
  5. Fiery chili sauce
  6. Gluten free pizza
  7. Super easy vegetarian pasta bake
  8. Victoria sponge cake
  9. Watercress soup

Proposed resolution

So far:
Get the language_code in EntityResource.php's getCollectionQuery method and pass to entity query

Remaining tasks

Review

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
JSON API 

Last updated about 5 hours ago

Created by

🇺🇸United States PCate

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.69.0 2024