From f2525e9edbf405feeff626143c04a2e6f6ed1fe6 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 14 Mar 2022 15:52:13 +0200 Subject: [PATCH 1/2] 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 e64df4ce..15c23431 100644 --- a/src/select/expr_term.rs +++ b/src/select/expr_term.rs @@ -168,6 +168,7 @@ where for result_value in &ret { if (*map_value).eq(*result_value) { tmp.push(*rel_value); + break; } } } From b4b07eebf8a68ab0e3812e59f9cd18d04c75bbf3 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 14 Mar 2022 16:06:00 +0200 Subject: [PATCH 2/2] Add test --- tests/array_filter.rs | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/array_filter.rs b/tests/array_filter.rs index 9ffa79ed..3c52a85c 100644 --- a/tests/array_filter.rs +++ b/tests/array_filter.rs @@ -250,4 +250,42 @@ fn bugs40_bracket_notation_after_recursive_descent() { "more" ]), ); -} \ No newline at end of file +} + +#[test] +fn bugs92_duplicate_result_similar_indernal_values() { + setup(); + + select_and_then_compare( + "$[?(@.name.first=='A')]", + json!([ + { + "name":{ + "first":"A" + } + }, + { + "name":{ + "first":"A" + } + }, + { + "name":{ + "first":"B" + } + } + ]), + json!([ + { + "name":{ + "first":"A" + } + }, + { + "name":{ + "first":"A" + } + } + ]), + ); +}