From d10f7554ab693c2565961d0c6b3b21390b9b172a Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 14 Mar 2022 15:50:17 +0200 Subject: [PATCH 1/3] Break after the first equals result_value to avoid duplicates --- src/select/expr_term.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/select/expr_term.rs b/src/select/expr_term.rs index 0130913e..9e2746c4 100644 --- a/src/select/expr_term.rs +++ b/src/select/expr_term.rs @@ -107,6 +107,7 @@ impl<'a> ExprTerm<'a> { for result_value in &ret { if map_value.eq(*result_value) { tmp.push(*rel_value); + break; } } } From 74ca9dbef8cc6bc2022b8c3d58b50b1015313bf2 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 14 Mar 2022 16:08:09 +0200 Subject: [PATCH 2/3] Add test --- tests/array_filter.rs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/array_filter.rs b/tests/array_filter.rs index 7f1cf332..a80b0e73 100644 --- a/tests/array_filter.rs +++ b/tests/array_filter.rs @@ -261,4 +261,39 @@ fn bugs50() { json!({"f": [1,2,3]}), json!([]) ); -} \ No newline at end of file +} + +#[test] +fn bugs40_bracket_notation_after_recursive_descent() { + setup(); + + select_and_then_compare( + "$..[0]", + json!([ + "first", + { + "key": [ + "first nested", + { + "more": [ + {"nested": ["deepest", "second"]}, + ["more", "values"] + ] + } + ] + } + ]), + json!([ + "first", + "first nested", + { + "nested" : [ + "deepest", + "second" + ] + }, + "deepest", + "more" + ]), + ); +} From 08c3bf00762ea3ead4f1147748a95ddc4fa8f2f5 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 14 Mar 2022 16:39:26 +0200 Subject: [PATCH 3/3] Update array_filter.rs --- tests/array_filter.rs | 47 +++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/tests/array_filter.rs b/tests/array_filter.rs index a80b0e73..d9ede8cc 100644 --- a/tests/array_filter.rs +++ b/tests/array_filter.rs @@ -264,36 +264,39 @@ fn bugs50() { } #[test] -fn bugs40_bracket_notation_after_recursive_descent() { +fn bugs92_duplicate_result_similar_indernal_values() { setup(); select_and_then_compare( - "$..[0]", + "$[?(@.name.first=='A')]", json!([ - "first", { - "key": [ - "first nested", - { - "more": [ - {"nested": ["deepest", "second"]}, - ["more", "values"] - ] - } - ] + "name":{ + "first":"A" + } + }, + { + "name":{ + "first":"A" + } + }, + { + "name":{ + "first":"B" + } } ]), json!([ - "first", - "first nested", - { - "nested" : [ - "deepest", - "second" - ] - }, - "deepest", - "more" + { + "name":{ + "first":"A" + } + }, + { + "name":{ + "first":"A" + } + } ]), ); }