jet
jet copied to clipboard
Support `[NULLS { FIRST | LAST }]` for `jet.OrderByClause`
Is your feature request related to a problem? Please describe.
The type OrderByClause does not support optional [NULLS { FIRST | LAST }] (PostgreSQL) expression, Causing Nulls always being first when using descending ordering
SELECT * FROM tbl ORDER BY key DESC NULLS LAST
Same thing applies to MySQL/MariaDB, except they sort Null values first when using ascending ordering, and it has a different syntax for controlling it, and I was not able to find anything in the documents that explains about this behavior.
SELECT * FROM tbl ORDER BY -key ASC (notice the - before key)
Describe the solution you'd like
Exposing methods (IMHO NullsFirst, NullsLast seem clear enough) for controlling where do nulls appear through OrderByClause could be helpful in lots of cases
Agree, make sense. :+1:
As a workaround, you can check if key is null:
SELECT *
FROM tbl
ORDER BY key is null, key DESC
NULLS_FIRST/NULLS_LAST support added in Release v2.11.0.