Expand description
§Convert Sort Expression to SQL
Converts ‘sort format’ to ‘SQL format’. E.g.:
-id
->id DESC NULLS LAST
id
->id ASC NULLS LAST
id-
->id ASC NULLS FIRST
-aired,id
->aired DESC NULLS LAST, id ASC NULLS LAST
§Example
#![allow(unstable)]
assert!(
sort_str_to_sql("-id") ==
Some("id DESC NULLS LAST".to_owned())
);
assert!(
sort_str_to_sql("-id,+aired-") ==
Some("id DESC NULLS LAST, aired ASC NULLS FIRST".to_owned())
);
(See tests for more examples.)
Functions§
- sort_
str_ to_ sql - Convert Sort Expression to SQL