jsonpath
jsonpath copied to clipboard
Fix for negating a filter script
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 $[?([email protected]_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.
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.
@joshbuddy Could you please review it?