1 unstable release

Uses old Rust 2015

0.1.0 Mar 28, 2018

#6 in #mapbox

MIT license

9KB
161 lines

mapbox-expressions-to-sql

Build Status

Transform Mapbox GL style specification decision expressions to SQL WHERE clause conditions.

Documentation

Documentation is here

Usage

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;

Example

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.

Dependencies

~370–780KB
~17K SLoC