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

Using try or ? breaks the update operator (|=) #1585

Closed
thedward opened this issue Jan 25, 2018 · 3 comments
Closed

Using try or ? breaks the update operator (|=) #1585

thedward opened this issue Jan 25, 2018 · 3 comments
Labels

Comments

@thedward
Copy link

thedward commented Jan 25, 2018

Using try or ? on the RHS of the |= operator removes the path being updated, even if the update expression works correctly without any error handling.

I'm using jq-1.6rc1-1-g61edf3f

Example program:

{"number":"1234"}|(.number|=23),(.number|=23?)

Expected output:

{
  "number": 23
}
{
  "number": 23
}

Actual output:

{
  "number": 23
}
{}

jq 1.5 behaves as expected.

@nicowilliams
Copy link
Contributor

Thanks for the report.

@earnestlukaskroupa
Copy link

earnestlukaskroupa commented Aug 12, 2019

This issue is still present in stable release jq-1.6.

I've tried following test cases:
{"price": "$23,000"} | .price |= (try 2 catch null)
{"price": null} # expected 2

The output is correct If update operator or try-catch is removed:
{"price": "$23,000"} | . + {price: (try 2 catch null)}
{ "price": 2}
{"price": "$23,000"} | .price |= 2
{ "price": 2}

Jq-1.5 works as expected. Is there any update on this issue? Is it related to the documented change of behavior of update operator?

@nicowilliams
Copy link
Contributor

Fixed by @wtlangford with e74eab8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants