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

Cannot order by multiple columns #775

Open
justinsunyt opened this issue Apr 17, 2024 · 1 comment
Open

Cannot order by multiple columns #775

justinsunyt opened this issue Apr 17, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@justinsunyt
Copy link

Bug report

Describe the bug

When trying to order multiple columns by using multiple .order() modifiers on a select function, the result only orders by the first column specified.

To Reproduce

Here is my code to get some rows from a table, which is then ordered first by last_chatted and then by created_at.

response = (
    supabase.table("clones")
    .select("*")
    .eq("owner", uid)
    .order("last_chatted", desc=True)
    .order("created_at", desc=True)
    .execute()
)

Expected behavior

The response should be ordered by last_chatted, and then created_at. However, this is not the case and the result is only ordered by last_chatted. I have confirmed that when I only order by last_chatted and created_at separately the code works as expected. I have also confirmed using the sort by visualization on my Supabase dashboard that the chained ordering is different from the result I get.

System information

  • OS: macOS
  • supabase: 2.4.2

Additional context

The same issue was reported in Discord in December, but no GitHub issue was created.

@justinsunyt justinsunyt added the bug Something isn't working label Apr 17, 2024
@silentworks
Copy link
Contributor

silentworks commented May 22, 2024

What results do you get when you run this same query in the SQL editor? from my tests I get the same result from the SQL editor and the library. Here is the SQL equivalent of your code above:

SELECT *
FROM "public"."clones"
WHERE "owner" = 'your_uid_here'
ORDER BY "last_chatted" DESC, "created_at" DESC;

@silentworks silentworks self-assigned this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants