[LIQ] Add nulls first / nulls last to order by

Extend the `order by` clause with optional `nulls first` and `nulls
last` modifiers following standard SQL semantics. Each sort key can
independently specify where `nil` values should appear in the result. By
default, ascending sorts place nulls last and descending sorts place
nulls first. An explicit nulls first or nulls last overrides this
default. The `asc` keyword is also now accepted as an explicit
alternative to the default ascending direction. Documentation and tests
were updated accordingly.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
This commit is contained in:
Matouš Jan Fialka
2026-03-02 12:34:25 +01:00
parent 8f193dc402
commit ff6854f6ee
10 changed files with 314 additions and 40 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ FromClause { ckw<"from"> (Name "=")? exp }
WhereClause { ckw<"where"> exp }
LimitClause { ckw<"limit"> exp ("," exp)? }
OrderByClause { ckw<"order"> ckw<"by"> list<OrderBy> }
OrderBy { exp ckw<"desc">? }
OrderBy { exp (ckw<"desc"> | ckw<"asc">)? (ckw<"nulls"> (ckw<"first"> | ckw<"last">))? }
SelectClause { ckw<"select"> exp }
GroupByClause { ckw<"group"> ckw<"by"> list<exp> }
HavingClause { ckw<"having"> exp }