From bae8ab08b528362d45f59584f9fd42f022cdddf0 Mon Sep 17 00:00:00 2001 From: mohanapriya2308 <57559402+mohanapriya2308@users.noreply.github.com> Date: Mon, 15 May 2023 15:58:48 +0530 Subject: [PATCH 1/6] Update enumerable.rb --- lib/jsonpath/enumerable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jsonpath/enumerable.rb b/lib/jsonpath/enumerable.rb index 75fb629..7b553f7 100644 --- a/lib/jsonpath/enumerable.rb +++ b/lib/jsonpath/enumerable.rb @@ -155,7 +155,7 @@ def process_function_or_literal(exp, default = nil) return nil unless @_current_node identifiers = /@?((? Date: Mon, 15 May 2023 16:02:39 +0530 Subject: [PATCH 2/6] Update enumerable.rb --- lib/jsonpath/enumerable.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/jsonpath/enumerable.rb b/lib/jsonpath/enumerable.rb index 7b553f7..ebc9b11 100644 --- a/lib/jsonpath/enumerable.rb +++ b/lib/jsonpath/enumerable.rb @@ -163,7 +163,6 @@ def process_function_or_literal(exp, default = nil) return default end end - JsonPath::Parser.new(@_current_node, @options).parse(exp) end end end From 7aa2052704bee3b63013e87047226312d4d58603 Mon Sep 17 00:00:00 2001 From: mohanapriya2308 <57559402+mohanapriya2308@users.noreply.github.com> Date: Mon, 15 May 2023 18:16:18 +0530 Subject: [PATCH 3/6] filter elements with unknown key --- lib/jsonpath/enumerable.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/jsonpath/enumerable.rb b/lib/jsonpath/enumerable.rb index ebc9b11..29660ab 100644 --- a/lib/jsonpath/enumerable.rb +++ b/lib/jsonpath/enumerable.rb @@ -154,8 +154,9 @@ def process_function_or_literal(exp, default = nil) return Integer(exp) if exp[0] != '(' return nil unless @_current_node - identifiers = /@?((? Date: Mon, 15 May 2023 18:17:37 +0530 Subject: [PATCH 4/6] Update test_jsonpath.rb --- test/test_jsonpath.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/test_jsonpath.rb b/test/test_jsonpath.rb index db8a5e4..2c46162 100644 --- a/test/test_jsonpath.rb +++ b/test/test_jsonpath.rb @@ -885,12 +885,17 @@ def test_complex_nested_grouping path = "$..book[?((@['author'] == 'Evelyn Waugh' || @['author'] == 'Herman Melville') && (@['price'] == 33 || @['price'] == 9))]" assert_equal [@object['store']['book'][2]], JsonPath.new(path).on(@object) end + + def test_nested_with_unknown_key + path = "$..[?(@.price == 9 || @.price == 33)].title" + assert_equal ["Sayings of the Century", "Moby Dick", "Sayings of the Century", "Moby Dick"], JsonPath.new(path).on(@object) + end - def test_complex_nested_grouping_unmatched_parent - path = "$..book[?((@['author'] == 'Evelyn Waugh' || @['author'] == 'Herman Melville' && (@['price'] == 33 || @['price'] == 9))]" - err = assert_raises(ArgumentError, 'should have raised an exception') { JsonPath.new(path).on(@object) } - assert_match(/unmatched parenthesis in expression: \(\(false \|\| false && \(false \|\| true\)\)/, err.message) + def test_nested_with_unknown_key_filtered_array + path = "$..[?(@['price'] == 9 || @['price'] == 33)].title" + assert_equal ["Sayings of the Century", "Moby Dick", "Sayings of the Century", "Moby Dick"], JsonPath.new(path).on(@object) end + def test_runtime_error_frozen_string skip('in ruby version below 2.2.0 this error is not raised') if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.0') || Gem::Version.new(RUBY_VERSION) > Gem::Version::new('2.6') From 647829b6459d14858ab128370ef75fe26746eac5 Mon Sep 17 00:00:00 2001 From: mohanapriya2308 <57559402+mohanapriya2308@users.noreply.github.com> Date: Mon, 15 May 2023 18:19:24 +0530 Subject: [PATCH 5/6] dummy commit --- test/test_jsonpath.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_jsonpath.rb b/test/test_jsonpath.rb index 2c46162..6940f20 100644 --- a/test/test_jsonpath.rb +++ b/test/test_jsonpath.rb @@ -896,7 +896,6 @@ def test_nested_with_unknown_key_filtered_array assert_equal ["Sayings of the Century", "Moby Dick", "Sayings of the Century", "Moby Dick"], JsonPath.new(path).on(@object) end - def test_runtime_error_frozen_string skip('in ruby version below 2.2.0 this error is not raised') if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.0') || Gem::Version.new(RUBY_VERSION) > Gem::Version::new('2.6') json = ' From 695630cafcdd48eb53f6013aec1ade36f349fd10 Mon Sep 17 00:00:00 2001 From: mohanapriya2308 <57559402+mohanapriya2308@users.noreply.github.com> Date: Mon, 15 May 2023 18:41:07 +0530 Subject: [PATCH 6/6] Update test.yml --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09e92c2..97a9c96 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,9 @@ jobs: - '2.5' - '2.6' - '2.7' + - '3.2' + - '3.1' + - '3.0' - ruby-head - jruby-head - truffleruby-head