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

Closed
zozowell opened this issue Oct 14, 2024 · 2 comments · Fixed by #2210
Closed

delete doesn't work as expected in ireduce #2172

zozowell opened this issue Oct 14, 2024 · 2 comments · 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
Contributor

I think this is a duplicate of #2027

@mikefarah
Copy link
Owner

Fixed in 4.4.6

tmeijn pushed a commit to tmeijn/dotfiles that referenced this issue Dec 9, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mikefarah/yq](https://github.com/mikefarah/yq) | patch | `v4.44.5` -> `v4.44.6` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>mikefarah/yq (mikefarah/yq)</summary>

### [`v4.44.6`](https://github.com/mikefarah/yq/releases/tag/v4.44.6)

[Compare Source](mikefarah/yq@v4.44.5...v4.44.6)

-   Fixed deleting items in array bug [#&#8203;2027](mikefarah/yq#2027), [#&#8203;2172](mikefarah/yq#2172); Thanks [@&#8203;jandubois](https://github.com/jandubois)
    -   Docker image for armv7 / raspberry pi3, Thanks [@&#8203;brianegge](https://github.com/brianegge)
    -   Fixed no-colors regression [#&#8203;2218](mikefarah/yq#2218)
    -   Fixed various panic scenarios [#&#8203;2211](mikefarah/yq#2211)
    -   Bumped dependencies

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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.

5 participants
@jandubois @mikefarah @zozowell and others