add nulls first/last support to order by expression (#176)

Following `<sort specification list>` from the standard https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#_10_10_sort_specification_list
This commit is contained in:
QP Hou 2020-05-30 07:05:15 -07:00 committed by GitHub
parent c918ff042d
commit 418b9631ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 8 deletions

View file

@ -2015,7 +2015,20 @@ impl Parser {
} else {
None
};
Ok(OrderByExpr { expr, asc })
let nulls_first = if self.parse_keywords(vec!["NULLS", "FIRST"]) {
Some(true)
} else if self.parse_keywords(vec!["NULLS", "LAST"]) {
Some(false)
} else {
None
};
Ok(OrderByExpr {
expr,
asc,
nulls_first,
})
}
/// Parse a TOP clause, MSSQL equivalent of LIMIT,