1
[Supabase-js] Support ordering numeric column ascending but push zeros and/or negatives to the end
Source: supabase/supabase#38661 · opened by @JFGHT
Description
Currently, .order(column, { ascending: true }) in Supabase-JS only allows basic ascending/descending sorting.
There is no way to push specific values such as 0 (or all non-positive values) to the end while keeping natural ordering for the rest.
In SQL this is often achieved with expressions like:
Use cases / motivation
• Treat 0 as a “default / empty” value that should not appear before meaningful positive values.
• Group all non-positive values (<= 0) at the end, keeping positives first.
• Allow custom ordering logic for datasets where certain values should appear later in UI lists or reports.
• Avoid requiring raw SQL or stored procedures for what is a common data presentation requirement.
Proposed API
Extend .order() with new options, for example:
Alternatively, support SQL expressions inside .order():
Currently, .order(column, { ascending: true }) in Supabase-JS only allows basic ascending/descending sorting.
There is no way to push specific values such as 0 (or all non-positive values) to the end while keeping natural ordering for the rest.
In SQL this is often achieved with expressions like:
Use cases / motivation
• Treat 0 as a “default / empty” value that should not appear before meaningful positive values.
• Group all non-positive values (<= 0) at the end, keeping positives first.
• Allow custom ordering logic for datasets where certain values should appear later in UI lists or reports.
• Avoid requiring raw SQL or stored procedures for what is a common data presentation requirement.
Proposed API
Extend .order() with new options, for example:
Alternatively, support SQL expressions inside .order():
No pledges yet. Be the first to back this.
Comments
Similar requests
[Supabasejs] support modify fetch option in http request
2 votes · 0 comments
Support ordering by nested columns deeper than one level in .order()
3 votes · 0 comments
Queue detail page: allow sorting messages by date descending (newest first)
1 vote · 0 comments
Support updating and displaying `numeric` data type precision and scale within Table Editor UI
22 votes · 0 comments
Improve Column Name Copying and Visibility in Tables
1 vote · 0 comments
No comments yet.