joshbuddy / jsonpath

Ruby implementation of http://goessner.net/articles/JsonPath/
MIT License
447 stars 72 forks source link

Fix for negating a filter script #152

Open evansalter opened 1 year ago

evansalter commented 1 year ago

Fixes https://github.com/joshbuddy/jsonpath/issues/151

Added a check for the situation where ! is the operator, and there is no operand. This allows us to use a JSONPath like $[?(!@['pull_request'])] or $[?(!@.pull_request)] where we want to receive the items from an array that don't have a pull_request key.

Open to feedback on this. I know it's not an overly generic fix, but this seems like a pretty specific edge case, so I figured a specific check would be warranted.

evansalter commented 1 year ago

Test output (no regressions):

❯ rake test
Run options: --seed 58270

# Running tests:

................................................................................................SS.................

Finished tests in 0.343056s, 335.2222 tests/s, 574.2503 assertions/s.

115 tests, 197 assertions, 0 failures, 0 errors, 2 skips
Coverage report generated for MiniTest to /Users/evansalter/dev/jsonpath/coverage. 352 / 361 LOC (97.51%) covered.
Parth-Rewind commented 1 year ago

@joshbuddy Could you please review it?