Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort by a nested key #11880

Closed
3 tasks done
travenec opened this issue Feb 27, 2022 · 5 comments
Closed
3 tasks done

Sort by a nested key #11880

travenec opened this issue Feb 27, 2022 · 5 comments

Comments

@travenec
Copy link

travenec commented Feb 27, 2022

Preflight Checklist

Describe the Bug

Hello everyone,

seems there is a trouble with sorting by a nested key.

Let's say I have a collection video which contains one file (M2O).

The endpoint /items/video?fields=*,file.*&sort=id correctly produces:

{
  data: [
    {
      id: "video1",
      status: "draft",
      ...
      file: {
        id: "491fc5a7-45fa-4320-9f12-3dbf4625bd3a",
        storage: "local",
        title: "Video 1 lowres",
        type: "video/mp4",
        ...
      }
    },
    {
      id: "video2",
      status: "draft",
      ...
      file: {
        id: "b9e710ce-8210-4270-aec2-a80bb26cb390",
        storage: "local",
        title: "Video 2 lowres",
        type: "video/mp4",
        ...
      }
    }
  ]
}

What fails is when I sort the date by nested key, e.g. file.title. Calling /iitems/video?fields=*,file.*&sort=file.title produces INTERNAL_SERVER_ERROR.

To Reproduce

It can be easily reproduced by creating a O2M relationship and trying sort by a nested key as described step by step above.

Errors Shown

The message in server console is:

🚨 error select "video"."id", "video"."status", ..., "video"."file" from "video" order by "video"."file"."title" asc limit $1 - missing FROM-clause entry for table "file" 
error: select "video"."id", "video"."status", ..., "video"."file" from "video" order by "video"."file"."title" asc limit $1 - missing FROM-clause entry for table "file"

What version of Directus are you using?

9.4.0 / 9.5.2

What version of Node.js are you using?

v16.13.0

What database are you using?

Postgres 14

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying Directus?

locally, Docker

@Lukas-Sachse
Copy link

Lukas-Sachse commented Feb 28, 2022

This functionality is not implemented yet. Look at this discussion: #4502

@travenec
Copy link
Author

I see. Sorry about that, did check all the issues, did not check discussion for this topic.

Wouldn't it be meaningful to mention that in docs?

@rijkvanzanten
Copy link
Member

Wouldn't it be meaningful to mention that in docs?

I'm not sure! Generally speaking, the documentation lists/explains all the features that exist. Otherwise, they can virtually get infinitely big (as there's always another feature somebody could want for something) 🤔 (cc @erondpowell)

@rijkvanzanten
Copy link
Member

For now, this is a duplicate of #4502 👍🏻

@erondpowell
Copy link
Contributor

erondpowell commented Feb 28, 2022

I'm not sure! Generally speaking, the documentation lists/explains all the features that exist. Otherwise, they can virtually get infinitely big (as there's always another feature somebody could want for something) 🤔 (cc @erondpowell)

I think this whole category of questions will be resolved once we have that dynamic FAQ system properly implemented.
Non-features like this will become a question, living right below the doc, on the relevant page.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants