mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-24 17:02:16 +00:00
fix return_type_for_child_object_not_matched
This commit is contained in:
parent
d855c17899
commit
218321a4bd
12
.idea/runConfigurations/filter.xml
generated
12
.idea/runConfigurations/filter.xml
generated
@ -1,12 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="filter" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="test --package jsonpath_lib --test filter """ />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="nocapture" value="false" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
12
.idea/runConfigurations/lib.xml
generated
12
.idea/runConfigurations/lib.xml
generated
@ -1,12 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="lib" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="test --package jsonpath_lib --test lib """ />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="nocapture" value="false" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
12
.idea/runConfigurations/mutable.xml
generated
12
.idea/runConfigurations/mutable.xml
generated
@ -1,12 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="mutable" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="test --package jsonpath_lib --test mutable """ />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="nocapture" value="false" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
12
.idea/runConfigurations/readme.xml
generated
12
.idea/runConfigurations/readme.xml
generated
@ -1,12 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="readme" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="test --package jsonpath_lib --test readme """ />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="nocapture" value="false" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
10
.travis.yml
10
.travis.yml
@ -24,15 +24,9 @@ matrix:
|
||||
before_script:
|
||||
- rustup component add clippy
|
||||
script:
|
||||
- cargo clean
|
||||
- cargo clippy -- -D warnings
|
||||
- cargo build --verbose --all
|
||||
- cargo clippy --all-targets --all-features -- -D warnings -A clippy::cognitive_complexity
|
||||
- cargo test --verbose --all
|
||||
- cd wasm && cargo clippy -- -D warnings -A clippy::suspicious_else_formatting
|
||||
- cd ../../
|
||||
- ./clippy.sh
|
||||
after_success: |
|
||||
cargo tarpaulin --exclude-files nodejs wasm parser/mod.rs --out Xml
|
||||
cargo tarpaulin --exclude-files wasm parser/mod.rs --out Xml
|
||||
bash <(curl -s https://codecov.io/bash)
|
||||
- rust: stable
|
||||
os: osx
|
||||
|
11
clippy.sh
Executable file
11
clippy.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
cargo clean
|
||||
cargo clippy -- -D warnings
|
||||
cargo build --verbose --all
|
||||
cargo clippy --all-targets --all-features -- -D warnings -A clippy::cognitive_complexity
|
||||
cargo test --verbose --all
|
||||
cd wasm && cargo clippy -- -D warnings -A clippy::suspicious_else_formatting
|
||||
cd ../
|
@ -710,18 +710,38 @@ impl<'a, 'b> Selector<'a, 'b> {
|
||||
}
|
||||
|
||||
fn next_from_current_with_num(&mut self, index: f64) {
|
||||
if let Some(current) = self.current.take() {
|
||||
let mut tmp = Vec::new();
|
||||
for c in current {
|
||||
if let Value::Array(vec) = c {
|
||||
fn _collect<'a>(tmp: &mut Vec<&'a Value>, vec: &'a [Value], index: f64) {
|
||||
let index = abs_index(index as isize, vec.len());
|
||||
if let Some(v) = c.get(index) {
|
||||
if let Some(v) = vec.get(index) {
|
||||
tmp.push(v);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(current) = self.current.take() {
|
||||
let mut tmp = Vec::new();
|
||||
for c in current {
|
||||
match c {
|
||||
Value::Object(map) => {
|
||||
for k in map.keys() {
|
||||
if let Some(Value::Array(vec)) = map.get(k) {
|
||||
_collect(&mut tmp, vec, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
Value::Array(vec) => {
|
||||
_collect(&mut tmp, vec, index);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
if tmp.is_empty() {
|
||||
self.terms.pop();
|
||||
self.current = Some(vec![&Value::Null]);
|
||||
} else {
|
||||
self.current = Some(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
debug!(
|
||||
"next_from_current_with_num : {:?}, {:?}",
|
||||
@ -729,27 +749,6 @@ impl<'a, 'b> Selector<'a, 'b> {
|
||||
);
|
||||
}
|
||||
|
||||
fn next_from_current_with_str(&mut self, keys: &[String]) {
|
||||
if let Some(current) = self.current.take() {
|
||||
let mut tmp = Vec::new();
|
||||
for c in current {
|
||||
if let Value::Object(map) = c {
|
||||
for key in keys {
|
||||
if let Some(v) = map.get(key) {
|
||||
tmp.push(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.current = Some(tmp);
|
||||
}
|
||||
|
||||
debug!(
|
||||
"next_from_current_with_str : {:?}, {:?}",
|
||||
keys, self.current
|
||||
);
|
||||
}
|
||||
|
||||
fn next_all_from_current(&mut self) {
|
||||
if let Some(current) = self.current.take() {
|
||||
let mut tmp = Vec::new();
|
||||
@ -774,6 +773,32 @@ impl<'a, 'b> Selector<'a, 'b> {
|
||||
debug!("next_all_from_current : {:?}", self.current);
|
||||
}
|
||||
|
||||
fn next_from_current_with_str(&mut self, keys: &[String]) {
|
||||
if let Some(current) = self.current.take() {
|
||||
let mut tmp = Vec::new();
|
||||
for c in current {
|
||||
if let Value::Object(map) = c {
|
||||
for key in keys {
|
||||
if let Some(v) = map.get(key) {
|
||||
tmp.push(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if tmp.is_empty() {
|
||||
self.current = Some(vec![&Value::Null]);
|
||||
} else {
|
||||
self.current = Some(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
debug!(
|
||||
"next_from_current_with_str : {:?}, {:?}",
|
||||
keys, self.current
|
||||
);
|
||||
}
|
||||
|
||||
fn all_from_current(&mut self) {
|
||||
if let Some(current) = self.current.take() {
|
||||
let mut tmp = Vec::new();
|
||||
|
@ -1,6 +1,8 @@
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use common::{read_json, select_and_then_compare, setup};
|
||||
|
||||
mod common;
|
||||
@ -53,14 +55,14 @@ fn return_type_for_child_object_matched() {
|
||||
);
|
||||
}
|
||||
|
||||
// #[test]
|
||||
#[test]
|
||||
fn return_type_for_child_object_not_matched() {
|
||||
setup();
|
||||
|
||||
select_and_then_compare(
|
||||
"$.school[?(@.friends[10])]",
|
||||
read_json("./benchmark/data_obj.json"),
|
||||
json!([]),
|
||||
json!([Value::Null]),
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user