Skip to content

Conversation

laurenceisla
Copy link
Member

@laurenceisla laurenceisla commented May 27, 2025

Closes #4075

(In stand-by for a major release)


it "ordering embeded entities with alias" $
get "/projects?id=eq.1&select=id, name, the_tasks:tasks(id, name)&tasks.order=name.asc" `shouldRespondWith`
get "/projects?id=eq.1&select=id, name, the_tasks:tasks(id, name)&the_tasks.order=name.asc" `shouldRespondWith`
Copy link
Member Author

@laurenceisla laurenceisla May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice that we allow using the table name as filter even when the alias is present. This is the only test that mentions this, but I don't think this is expected, right?

From now on, this would fail with an error like:

GET /projects?id=eq.1&select=id, name, the_tasks:tasks(id, name)&tasks.order=name.asc
{
  "code":"PGRST108",
  "details":null,
  "hint":"Verify that 'tasks' is included in the 'select' query parameter.",
  "message":"'tasks' is not an embedded resource in this request"
}

If this change is OK then more info to the hint would be needed like: "If it has an alias, then use it instead of the resource name".

If using the resource name as well as the alias is expected, then this would be a breaking change and the solution would be different. Maybe throw an error when there may be ambiguity (like in #2529).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From now on, this would fail with an error like:

This would also fail for filters, limits, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as you're only using one embedding for the same table, but with an alias, this is a working query right now. So, I'd say we only fix this in a major, otherwise people can't update to the latest patch without risking to break something that works.

@steve-chavez steve-chavez added the breaking change A bug fix or enhancement that would cause a breaking change label May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change A bug fix or enhancement that would cause a breaking change
Development

Successfully merging this pull request may close these issues.

Unexpected results when embedding and filtering the same table twice
3 participants