-
-
Notifications
You must be signed in to change notification settings - Fork 707
Description
Describe the bug
When select
ing by document index and constructing a string, the ignored documents are still used for string construction, but without any content.
Version of yq: v4.48.1
Operating system: Debian via WSL on Windows
Installed via: homebrew
Input Yaml
# test.yml
name: Alice
---
name: Bob
Command
The command you ran:
yq 'select(document_index==0) | "My name is \(.name)"' test.yml
Actual behavior
The string is constructed twice, but because the second document was not select
ed, there is no content.
My name is Alice
My name is
Expected behavior
I would have thought that the document that did not fit the select
criteria would be dropped entirely.
My name is Alice
Additional context
This only seems to happen when filtering by document index. If the YAML document contains an array and we select
on the array then pipe to a string, no strings are created for the unselected elements.
Perhaps I'm misunderstanding how the pipes or string interpolation are meant to be used. Maybe this is already documented somewhere, but I couldn't find anything. If this is intended behavior, a note in the documentation for interpolation or document filtering would be nice.