-
Notifications
You must be signed in to change notification settings - Fork 75
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
Cannot update against null #19
Comments
This is not just an issue of updating operator, but indexing issue?
|
Ok, so this history is a bit complicated.
Ok, so we cannot index numbers with strings. That is, there is no single number for which that operation makes sense. When I'm already talking about update operators: jq has this history of inventing values "from the air". For example:
Here, we update a single value of the array and implicitly grow the array at the same time. Now comes the question: Do you think that I should document these differences (of which there might be quite some) somewhere, and if so, where and in what form? In the README? In the tests? In the source? |
I respect your design because this is your product. But README.md states while preserving compatibility with jq in most cases, so users encountering the behavior difference of the most basic filter may get confused. I don't think the behavior of |
Ok, so I am currently drafting a section in the README about smaller differences between jaq and jq. |
I updated the README with a few differences in 0d00650, but this is surely not yet exhaustive. |
Thanks for listing jq difference in README.md. Another difference to be worth noticing is the behavior of updating with multiple paths; |
I agree, this feature makes jq quite powerful. I have already documented the difference. In the long run, I think it would be nice for jaq to also support this, but in the past, I have not yet achieved a nice way to implement this; that is, a way that is performant and that does not duplicate lots of code.
Fair point. So I just drafted some code that makes |
And on a related note: What should |
Also, |
By the way, my rationale is also consistent with the behaviour that |
I have a bit more formal specification of what I believe to need to hold for I call the neutral values: Proposal for operations on
For example, what about What about |
Making
Your formal specification looks a sophisticated way of reasoning the changes, but I can give a counter example with no explicit branching; |
Thank you for your counterexample! I will have to think about this a bit more ... On a different note, I have implemented in ab5c764 some initial support for updating with non-path expressions! This enables support for The implementation of the update operation should be significantly faster than in jq, because jaq does not explicitly construct paths. Furthermore, jaq aims to give more "intuitive" answers; for example, Still, the current implementation of updating in jaq is quite new, so if you find some bugs there, I'll be happy to fix them. :) |
That deletion issue of jq is well known (jqlang/jq#2051) and I suggested a fix two years ago (jqlang/jq#2133). |
Oh, that is interesting to read! I think it is a pity that your pull request was never integrated ... |
I'm closing because this is a design decision of jaq rather than a compatibility issue. |
While jq allows to construct object or array from
null
by updating, butjaq
throws errors.The text was updated successfully, but these errors were encountered: