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

Select not equal without spaces does not work #1711

Closed
arve0 opened this issue Jun 27, 2023 · 3 comments
Closed

Select not equal without spaces does not work #1711

arve0 opened this issue Jun 27, 2023 · 3 comments
Labels

Comments

@arve0
Copy link

arve0 commented Jun 27, 2023

Hi and thanks for yq πŸ™Œ I use it every day, it's great!

With multi-document, yq is unable to deselect a document when != operator does not have space around it.

Example:

❯ echo -e 'a: 1\n---\na: 2' | yq 'select(.a!=1)'
a: 1
---
a: 2

Expected output is a: 2.

Spaces around or before works as expected:

❯ echo -e 'a: 1\n---\na: 2' | yq 'select(.a != 1)'
a: 2

❯ echo -e 'a: 1\n---\na: 2' | yq 'select(.a !=1)'
a: 2

But not when space after, suggesting it is mixing .a and ! together:

❯ echo -e 'a: 1\n---\na: 2' | yq 'select(.a!= 1)'
a: 1
---
a: 2

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

Input Yaml
data.yaml:

a: 1
---
a: 2

Command

yq 'select(.a!=1)' data.yaml

Actual behavior

a: 1
---
a: 2

Expected behavior

a: 2

Additional context
Reported in #1377 also. Select with == without spaces works fine, for example select(.a==1).

I have not looked at the yq code, but I can give the bug a try if I get a pointer for where to look 😊 Assuming this is considered a bug.

mikefarah added a commit that referenced this issue Aug 29, 2023
@mikefarah
Copy link
Owner

That is odd. Looking at the code it thinks that the exclamation mark is part of the property name. Will fix in the next version :)

@mikefarah
Copy link
Owner

Also - glad you like yq :)

@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