sort_str_to_sql

Crates.iosort_str_to_sql
lib.rssort_str_to_sql
version1.0.0
sourcesrc
created_at2014-11-21 14:41:55.091122
updated_at2015-12-11 23:56:18.321051
descriptionConvert Sort Expression to SQL that can be used in 'ORDER BY' statement, e.g. '-aired,id' -> 'aird DESC NULLS LAST, id ASC NULLS LAST'.
homepagehttps://github.com/killercup/rust-sortStringToSql
repositoryhttps://github.com/killercup/rust-sortStringToSql
max_upload_size
id306
size6,891
Pascal Hertleif (killercup)

documentation

README

Sort String To SQL

This is a rust crate to convert 'sort expressions' to SQL expressions that can be used in an 'ORDER BY'. E.g., -date,id will be converted to date DESC NULLS LAST, id ASC NULLS LAST.

It can be used to convert a HTTP query parameter to an expression that can be used in an SQL query. (I'm only using this with Postgres myself, so I can't promise you it will work with other databases.)

Build Status

Install

# Cargo.toml
[dependencies]
sort_str_to_sql = "1.0.0"

Input Format

Comma separated list of field names. Prepend a '-' for descending order or a '+' for ascending order (which is the default, so it's optional). Append a '-' if you want records with null values first (this sets NULLS FIRST).

You can find some examples in the inline #[test].

License

MIT

Commit count: 27

cargo fmt