Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to incorrect --stream paths #2010

Closed
wants to merge 2 commits into from

Conversation

cefn
Copy link

@cefn cefn commented Nov 14, 2019

Thought something was wrong with the example provided against the --stream option. Proved that the index of the path to "b" was incorrect by running the example on the terminal. Instead of [[1,0],"b"] it should read [[2,0],"b"] .

Additionally, this isn't the whole stream. Given it's a depth-first traversal, after visiting descendants, it will visit the paths of the ancestors too. However I guess these have been omitted deliberately for brevity?

If you prefer the full sequence I'll force push a fix to this PR branch which contains the ancestor paths traversed too.

Example in terminal

echo '[[],"a",["b"]]' | jq --stream --compact-output
[[0],[]]
[[1],"a"]
[[2,0],"b"]
[[2,0]]
[[2]]

Thought something was wrong with the example provided against the --stream option. Proved that the index of the path to "b" was incorrect by running the example on the terminal.  Instead of `[[1,0],"b"]` it should read `[[2,0],"b"]` . 

Additionally, this isn't the whole stream, as given it's depth-first, after visiting descendants, it will visit the ancestor containers too. However I guess these have been omitted deliberately for brevity? 

If you prefer the full sequence I'll force push a fix to this PR branch which contains the ancestors traversed too.  

## Example in terminal

```
echo '[[],"a",["b"]]' | jq --stream --compact-output
[[0],[]]
[[1],"a"]
[[2,0],"b"]
[[2,0]]
[[2]]
```
@coveralls
Copy link

coveralls commented Nov 14, 2019

Coverage Status

Coverage decreased (-0.4%) to 84.164% when pulling ec29d7e on cefn:fix-stream-manual-entry into bda75c3 on stedolan:master.

@cefn
Copy link
Author

cefn commented Nov 14, 2019

I noticed also #1279 which reports the issue and #1946 which is an alternate fix.

Comment on lines 119 to 120
`[[],"a",["b"]]` becomes `[[0],[]]`, `[[1],"a"]`, and
`[[2,0],"b"]`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   `[[],"a",["b"]]` becomes `[[0],[]]`, `[[1],"a"]`, `[[2,0],"b"]`,
   `[[2,0]]` and `[[2]]`.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed and committed to branch.

@itchyny
Copy link
Contributor

itchyny commented Jun 7, 2023

The original path error was fixed by #2387 (0171a9e). I think this section explains this option in briefly, and there is a full explanation in the Streaming section. I think this is okay, so closing the PR. Thank you.

@itchyny itchyny closed this Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants