Crates.io | mapbox_expressions_to_sql |
lib.rs | mapbox_expressions_to_sql |
version | 0.1.0 |
source | src |
created_at | 2018-03-28 08:39:27.737845 |
updated_at | 2018-03-28 08:39:27.737845 |
description | Iron router with regex captures support. |
homepage | https://github.com/stepankuzmin/rust-mapbox-expressions-to-sql |
repository | https://github.com/stepankuzmin/rust-mapbox-expressions-to-sql |
max_upload_size | |
id | 57874 |
size | 9,533 |
Transform Mapbox GL style specification decision expressions to SQL WHERE
clause conditions.
Documentation is here
Add this to your Cargo.toml
:
[dependencies]
mapbox_expressions_to_sql = "0.1"
and this to your crate root:
extern crate mapbox_expressions_to_sql;
extern crate mapbox_expressions_to_sql;
use mapbox_expressions_to_sql::parse;
assert_eq!(parse(r#"["has", "key"]"#).unwrap(), "key IS NOT NULL");
assert_eq!(parse(r#"["==", "key", 42]"#).unwrap(), "key = 42");
assert_eq!(parse(r#"["in", "key", "v0", "v1", "v2"]"#).unwrap(), "key IN ('v0', 'v1', 'v2')");
assert_eq!(parse(r#"["all", ["==", "key0", "value0"], ["==", "key1", "value1"]]"#).unwrap(), "key0 = 'value0' AND key1 = 'value1'");
See tests for more examples.