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

map(select(...)) does not remove entries #50

Open
kszafran opened this issue Nov 21, 2019 · 1 comment
Open

map(select(...)) does not remove entries #50

kszafran opened this issue Nov 21, 2019 · 1 comment
Labels

Comments

@kszafran
Copy link

I found a case where jackson-jq returns a different result from jq:

With jq (jq-1.6):

$ jq -cn '{key1: true, key2: false} | map_values(select(.))'
{"key1":true}

With jackson-jq (0.0.10) I get:

{"key1":true,"key2":null}

So key2 is not removed. Perhaps it has something to do with the |= operator, but the footnote in the readme mentions only throwing errors.

@eiiches
Copy link
Owner

eiiches commented Nov 21, 2019

Thank you for reporting! I've confirmed the issue.

$ jq-1.6 -cn '{key1: true, key2: false} | map_values(select(.))'
{"key1":true}
$ jq-1.5 -cn '{key1: true, key2: false} | map_values(select(.))'
null
$ java -jar jackson-jq-cli-0.0.10.jar -cn '{key1: true, key2: false} | map_values(select(.))'
{"key1":true,"key2":null}
$ java -jar jackson-jq-cli-1.0.0-preview.20190925.jar --jq 1.5 -cn '{key1: true, key2: false} | map_values(select(.))'
jq: error: `|= empty` is undefined. See https://github.com/stedolan/jq/issues/897
$ java -jar jackson-jq-cli-1.0.0-preview.20190925.jar --jq 1.6 -cn '{key1: true, key2: false} | map_values(select(.))'
jq: error: `|= empty` is undefined. See https://github.com/stedolan/jq/issues/897

As you've guessed, this is because map_values/1 is defined as def map_values(f): .[] |= f, where ... |= f is undefined when f is empty. I'm not yet sure what to do with this behavior...

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