We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Variables seem to be mixed up when using within a map.
map
Version of yq: 4.30.5 Operating system: mac Installed via: homebrew
Input Yaml Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less) input.yml:
key1: - value1A - value1B - value1C key2: - value2A - value2B - value2C
Command The command you ran:
yq e '. as $root | keys | map(select(. == "key1" or . == "key2") | . as $kind | $root[$kind] | map({"combination": ($kind + "/" + .)})) | flatten' input.yml
Actual behavior
- combination: key1/value1A - combination: key2/value1A - combination: key1/value1B - combination: key2/value1B - combination: key1/value1C - combination: key2/value1C - combination: key1/value2A - combination: key2/value2A - combination: key1/value2B - combination: key2/value2B - combination: key1/value2C - combination: key2/value2C
Expected behavior
- combination: key1/value1A - combination: key1/value1B - combination: key1/value1C - combination: key2/value2A - combination: key2/value2B - combination: key2/value2C
Additional context
I'm aware the the expression isn't fully optimized (e.g. pick could be used). But the very same expression works in jq:
pick
jq
yq -o=json input.yml | jq '. as $root | keys | map(select(. == "key1" or . == "key2") | . as $kind | $root[$kind] | map({"combination": ($kind + "/" + .)})) | flatten' -
results in:
[ { "combination": "key1/value1A" }, { "combination": "key1/value1B" }, { "combination": "key1/value1C" }, { "combination": "key2/value2A" }, { "combination": "key2/value2B" }, { "combination": "key2/value2C" } ]
which is the equivalent to the expected yaml.
The text was updated successfully, but these errors were encountered:
Thanks for the detailed bug description, this will be fixed in the next release along with #1566
Sorry, something went wrong.
Fixed in v4.31.2
No branches or pull requests
Describe the bug
Variables seem to be mixed up when using within a
map
.Version of yq: 4.30.5
Operating system: mac
Installed via: homebrew
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
input.yml:
Command
The command you ran:
Actual behavior
Expected behavior
Additional context
I'm aware the the expression isn't fully optimized (e.g.
pick
could be used). But the very same expression works injq
:results in:
which is the equivalent to the expected yaml.
The text was updated successfully, but these errors were encountered: