sort_str_to_sql 0.0.2

Convert Sort Expression to SQL that can be used in 'ORDER BY' statement, e.g. '-aired,id' -> 'aird DESC NULLS LAST, id ASC NULLS LAST'.
docs.rs failed to build sort_str_to_sql-0.0.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: sort_str_to_sql-1.0.0

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

# use sort_str_to_sql::{sort_str_to_sql};
assert!(
  sort_str_to_sql("-id") ==
  Some("id DESC NULLS LAST".to_string())
)
assert!(
  sort_str_to_sql("-id,+aired-") ==
  Some("id DESC NULLS LAST, aired ASC NULLS FIRST".to_string())
)

(See tests for more examples.)