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

inconsistent result when concatenating string with null #1712

Closed
ryenus opened this issue Jun 27, 2023 · 2 comments
Closed

inconsistent result when concatenating string with null #1712

ryenus opened this issue Jun 27, 2023 · 2 comments
Labels

Comments

@ryenus
Copy link
Contributor

ryenus commented Jun 27, 2023

Describe the bug
The result of string concatenation with null varies depending on the order:

Command Output
yq -n '"str" + null' -oj "strnull"
yq -n 'null + "str"' -oj "str"
jq -n '"str" + null' "str"
jq -n 'null + "str"' "str"

So when null was appended a string it end up as the string literal "null", but when appending a string to null, it end up as an empty string.

Meanwhile as a comparison, jq turns both null into "", namely empty strings.

Version of yq: 4.34.1
Operating system: mac
Installed via: homebrew

Expected behavior
I'd expect when converting null to a string, the result should be consistent in both case, regardless the order of the operands.

@mikefarah
Copy link
Owner

Thanks for raising - will update so that "str" + null = "str" :)

@mikefarah
Copy link
Owner

Fixed in 4.35.2

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

2 participants