Skip to content

feat(builtins): implement jq setpath, leaf_paths, fix match/scan#384

Merged
chaliy merged 1 commit intomainfrom
claude/fix-328-jq-features-Vvs93
Feb 27, 2026
Merged

feat(builtins): implement jq setpath, leaf_paths, fix match/scan#384
chaliy merged 1 commit intomainfrom
claude/fix-328-jq-features-Vvs93

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 27, 2026

Summary

  • Add setpath(p; v) and leaf_paths as custom jq definitions prepended to every filter, filling gaps in jaq's standard library
  • Fix match to include "name": null for unnamed capture groups (jaq omitted it)
  • Fix scan to use implicit global matching by prepending "g" flag (matching real jq behavior)
  • Enable 4 previously-skipped spec tests, reducing skip count from 18 to 14
  • The // alternative operator on null inputs remains skipped (requires jaq core changes)

Closes #328

Test plan

  • cargo test --all-features passes (113/114 jq spec tests pass, 1 skipped)
  • cargo fmt --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • Verify setpath test: echo '{"a":1}' | jq 'setpath(["b"];2)' outputs {"a":1,"b":2}
  • Verify leaf_paths test: echo '{"a":{"b":1}}' | jq '[leaf_paths]' outputs [["a","b"]]
  • Verify match test: unnamed captures include "name":null field
  • Verify scan test: [scan("hel")] on "hello hello" returns both matches

@chaliy chaliy force-pushed the claude/fix-328-jq-features-Vvs93 branch from 428fa20 to 03a27fb Compare February 27, 2026 23:14
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
@chaliy chaliy force-pushed the claude/fix-328-jq-features-Vvs93 branch from 03a27fb to 544e28d Compare February 27, 2026 23:40
@chaliy chaliy merged commit e201bf4 into main Feb 27, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement jq setpath, leaf_paths, and fix match/scan behavior

2 participants