feat(builtins): implement jq setpath, leaf_paths, fix match/scan#384
Merged
feat(builtins): implement jq setpath, leaf_paths, fix match/scan#384
Conversation
428fa20 to
03a27fb
Compare
Prepend custom jq definitions to every filter to patch jaq limitations: - setpath(p; v): recursive path-setting, not in jaq stdlib - leaf_paths: paths to scalar leaves via paths(scalars) - match: adds "name":null to unnamed captures (jaq omitted it) - scan: uses "g" flag for global matching (jq default behavior) The // alternative operator on null remains skipped (jaq core limitation). Enable 4 previously-skipped spec tests. Skip count: 18 -> 14. Closes #328 https://claude.ai/code/session_01QbjrsMFJbHy5XfHCzA6TjM
03a27fb to
544e28d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setpath(p; v)andleaf_pathsas custom jq definitions prepended to every filter, filling gaps in jaq's standard librarymatchto include"name": nullfor unnamed capture groups (jaq omitted it)scanto use implicit global matching by prepending "g" flag (matching real jq behavior)//alternative operator on null inputs remains skipped (requires jaq core changes)Closes #328
Test plan
cargo test --all-featurespasses (113/114 jq spec tests pass, 1 skipped)cargo fmt --checkcleancargo clippy --all-targets --all-features -- -D warningscleansetpathtest:echo '{"a":1}' | jq 'setpath(["b"];2)'outputs{"a":1,"b":2}leaf_pathstest:echo '{"a":{"b":1}}' | jq '[leaf_paths]'outputs[["a","b"]]matchtest: unnamed captures include"name":nullfieldscantest:[scan("hel")]on"hello hello"returns both matches