Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Closes #62.
A path through irregular data needed a
?on every step, and the result hadnullvalues that could not be traced to a step. Now one?on the step that can be absent is enough.?skips the rest of the path when its step givesnull, like?.in JavaScript.{} | .a?.b.cgivesnull. The path ends at|,,, an operator,??or a closing bracket, so(.a?).band.a? | .bstill fail.?stay strict:{"a": {}} | .a?.bis stillkey_not_found.?andtrywithoutcatchgive no output on a type mismatch, as jq does:"x" | .a?,1 | .[]?,123 | keys?. An absent value still givesnull: a missing key, a key or an index onnull, an index out of bounds,first?on[].?andtrywithoutcatchno longer hide an undefined function:foo?reports the error..[1:2]?parses without parentheses. A slice onnullor a number is an error; it used to stop with an OCamlAssertion failed.path(.a?.b.c)and.a?.b.c |= 9now work for paths of three or more steps, as the two-step forms already did.Optionalin the AST now holds the step and the rest of its path; a plain?hasIdentityas the rest. The interpreter runs the rest outside the error handler, so only the marked step is forgiven.Runtime_error.when_caughtis the one place that maps an error kind tonull, no output, or propagation.Differences from jq, on the issue's data:
main(2c08a49).users[].metadata?.preferences?[]?.notifications?.email?null,null,"bob@example.com"null,"bob@example.com""bob@example.com".users[].metadata?.preferences[].notifications?.emailnull_accessnull,"bob@example.com"... | valuesafter either query"bob@example.com"The proposal in #62 to skip missing values by default is not taken: plain access stays strict, which also covers the proposed
!.Checked at fbe6d6f with
dune test --force --root .: 867 runtime and parser tests and 103 reader tests pass. Each commit's new tests were run against its parent first and failed there.Risk: two-way door for the code; a revert restores the old
?. It is a breaking language change for users: queries that relied on?givingnullfor a type mismatch, or on anullflowing into the next step after?, give different output.CHANGES.mdanddocs/JQ_COMPATIBILITY.mddescribe it.