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

delete doesn't work as expected in ireduce #2172

Open
zozowell opened this issue Oct 14, 2024 · 1 comment · May be fixed by #2210
Open

delete doesn't work as expected in ireduce #2172

zozowell opened this issue Oct 14, 2024 · 1 comment · May be fixed by #2210
Labels

Comments

@zozowell
Copy link

Describe the bug
When I use delete operator in the ireduce block, the del doesn't work as I expected.

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

Input Yaml
test.yml:

- a: cat
- b: dog
- c: bat

Command
The command you ran:

A="[cat, bat]" yq 'env(A)[] as $a ireduce(.; del(.[] | select(.[] == $a)))' test.yaml

Actual behavior

bash-3.2$ A="[cat, bat]" yq 'env(A)[] as $a ireduce(.; del(.[] | select(.[] == $a)))' test.yaml
- b: dog
- c: bat

Expected behavior

bash-3.2$ A="[cat, bat]" yq 'env(A)[] as $a ireduce(.; del(.[] | select(.[] == $a)))' test.yaml
- b: dog

Additional context
The behavior is very weird as the input variable A changed; another strange behavior is that: I can't delete all the elements, even deleting the array index 0 every time.

bash-3.2$ A="[cat, bat, dog]" yq 'env(A)[] as $a ireduce(.; del(.[0]))' test.yaml
- b: dog
@jandubois
Copy link

I think this is a duplicate of #2027

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 a pull request may close this issue.

4 participants
@jandubois @zozowell and others