freestrings / jsonpath

JsonPath engine written in Rust. Webassembly and Javascript support too

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash using Filter with $

oshadmi opened this issue · comments

Add the following test to tests/filter.rs

#[test]
fn unsupported_in_filter() {
    setup();

    let json = json!([{
        "a": {"x": {"i": 10}},
        "b": {"x": {"i": 20, "j": 5}}
    }]);

    select_and_then_compare("$..x[?(@.i>10)]", json.clone(), json!([{"i": 20,"j": 5}]));

    // Should not panic ('empty term left')
    select_and_then_compare("$..x[?($.i>10)]", json.clone(), json!([]));
}

The filter ?($.i>10) panics
---- unsupported_in_filter stdout ----
thread 'unsupported_in_filter' panicked at 'empty term left', src/selector/selector_impl.rs:344:18
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace