Skip to content

Ordering nested tables doesn't work for more than 1 level #149

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

Closed
joshnuss opened this issue Jan 21, 2021 · 3 comments · Fixed by #155
Closed

Ordering nested tables doesn't work for more than 1 level #149

joshnuss opened this issue Jan 21, 2021 · 3 comments · Fixed by #155
Assignees
Labels
bug Something isn't working released

Comments

@joshnuss
Copy link

joshnuss commented Jan 21, 2021

Bug report

order() only works if joined table is one level deep.

To Reproduce

Run a query with multiple levels of joins:

My schema: boards -> has many lists -> has many cards.
Each table has a position column.

supabase
  .from('boards')
  .select('id, title, lists ( id, title, position, cards ( id, description, position ))') // 2-levels of nesting
  .order('position') // this works
  .order('position', {foreignTable: 'lists'}) // this works
  .order('position', {foreignTable: 'lists.cards'}) // this doesn't work

Expected behavior

Sorting should work on any level of nesting.

Research

PostgREST does support this, the issue is due to quoting of the foreignTable param here:

const key = typeof foreignTable === 'undefined' ? 'order' : `"${foreignTable}".order`

When I remove the quoting locally, the sorting works correctly.

@joshnuss joshnuss added the bug Something isn't working label Jan 21, 2021
@joshnuss joshnuss changed the title Ordering nested tables doesn't work Ordering nested tables doesn't work for more than 1 level Jan 21, 2021
@kiwicopple
Copy link
Member

@soedirgo was there any reason you added the quotes here?

@soedirgo
Copy link
Member

Seems like a continuation of #131. Same reason for quoting: to handle special characters.

I think we can just assume that 95% of table/column names don't have special characters, and just let users quote the names manually. It's leaky, but should stop issues like this from happening.

Places to update: order, limit, range, cleanFilterArray.

soedirgo added a commit that referenced this issue Feb 13, 2021
Automatically quoting tables/columns led to many unintended problems:
\#131, \#149. This removes all remaining quoting of names.
soedirgo added a commit that referenced this issue Feb 13, 2021
Automatically quoting tables/columns led to many unintended problems: #131, #149. This removes all remaining quoting of names.
@github-actions
Copy link

🎉 This issue has been resolved in version 0.24.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants