Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295286

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

$
0
0

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

interestingly, sorting in the reverse order with: /jsonapi/node/recipe?sort=-title seems to return the correct order:
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


Viewing all articles
Browse latest Browse all 295286

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>