Skip to content

Commit

Permalink
up version and fix clippy and fmt complains
Browse files Browse the repository at this point in the history
  • Loading branch information
besok committed Oct 26, 2023
1 parent 8a3457e commit 4e96013
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@
* introduce the different behaviour for empty results and non-existing result
* **`0.3.2`**
* make jsonpath inst cloneable.
* **`0.3.3`**
* fix a bug with the logical operators
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "jsonpath-rust"
description = "The library provides the basic functionality to find the set of the data according to the filtering query."
version = "0.3.2"
version = "0.3.3"
authors = ["BorisZhguchev <[email protected]>"]
edition = "2018"
license-file = "LICENSE"
Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl JsonPathFinder {
#[cfg(test)]
mod tests {
use crate::JsonPathQuery;
use crate::JsonPathValue::{NewValue, NoValue, Slice};
use crate::JsonPathValue::{NoValue, Slice};
use crate::{json_path_value, JsonPathFinder, JsonPathInst, JsonPathValue};
use serde_json::{json, Value};
use std::ops::Deref;
Expand Down Expand Up @@ -1073,8 +1073,7 @@ mod tests {

#[test]
fn logical_exp_test() {
let json: Box<Value> =
Box::new(json!({"first":{"second":[{"active":1},{"passive":1}]}}));
let json: Box<Value> = Box::new(json!({"first":{"second":[{"active":1},{"passive":1}]}}));

let path: Box<JsonPathInst> = Box::from(
JsonPathInst::from_str("$.first[?(@.does_not_exist && @.does_not_exist >= 1.0)]")
Expand All @@ -1085,7 +1084,6 @@ mod tests {
let v = finder.find_slice();
assert_eq!(v, vec![NoValue]);


let path: Box<JsonPathInst> = Box::from(
JsonPathInst::from_str("$.first[?(@.does_not_exist >= 1.0)]")
.expect("the path is correct"),
Expand Down
9 changes: 4 additions & 5 deletions src/path/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ impl<'a> FilterPath<'a> {
JsonPathValue::into_data(right),
JsonPathValue::into_data(left),
),
FilterSign::GrOrEq => FilterPath::compound(&FilterSign::Greater, &FilterSign::Equal, left, right),
FilterSign::GrOrEq => {
FilterPath::compound(&FilterSign::Greater, &FilterSign::Equal, left, right)
}
FilterSign::Regex => regex(
JsonPathValue::into_data(left),
JsonPathValue::into_data(right),
Expand Down Expand Up @@ -498,7 +500,6 @@ mod tests {
let exp3 = json!( {"field":4});
let exp4 = json!( {"field":1});


let index = path!(
idx!(?filter!(op!(path!(@, path!("field"))), ">", op!(chain!(path!($), path!("threshold")))))
);
Expand All @@ -507,7 +508,6 @@ mod tests {
let expected_res = json_path_value![&exp1, &exp2];
assert_eq!(path_inst.find((&json).into()), expected_res);


let index = path!(
idx!(?filter!(op!(path!(@, path!("field"))), ">=", op!(chain!(path!($), path!("threshold")))))
);
Expand All @@ -524,13 +524,12 @@ mod tests {
let expected_res = json_path_value![&exp4, &exp4];
assert_eq!(path_inst.find((&json).into()), expected_res);


let index = path!(
idx!(?filter!(op!(path!(@, path!("field"))), "<=", op!(chain!(path!($), path!("threshold")))))
);
let chain = chain!(path!($), path!("key"), index);
let path_inst = json_path_instance(&chain, &json);
let expected_res = json_path_value![&exp4,&exp3, &exp4];
let expected_res = json_path_value![&exp4, &exp3, &exp4];
assert_eq!(path_inst.find((&json).into()), expected_res);
}

Expand Down

0 comments on commit 4e96013

Please sign in to comment.