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 selector can't find keys with null values #346

Closed
srounce opened this issue Jul 27, 2023 · 2 comments · Fixed by #398
Closed

Delete selector can't find keys with null values #346

srounce opened this issue Jul 27, 2023 · 2 comments · Fixed by #398
Assignees
Labels
bug Something isn't working

Comments

@srounce
Copy link

srounce commented Jul 27, 2023

Describe the bug
Delete doesn't work for paths with null values.

To Reproduce
Steps to reproduce the behavior:

> echo '{ "foo": null }' | dasel delete -r json 'foo'

< Error: could not access map index: property not found: foo

Expected behavior
I'd expect it to return {} instead I get the error above.

  • OS: linux
  • Version 2.3.4
@srounce srounce added the bug Something isn't working label Jul 27, 2023
@TomWright
Copy link
Owner

I've had a look and this is a tough problem to solve.

Related: golang/go#51649

I'm going to do some thinking and come back to this.

@TomWright
Copy link
Owner

Thanks for your patience on this.

I believe I have resolved this issue, see:

$ echo '{"foo":null}' | ./dasel -r json
{
  "foo": null
}
$ echo '{"foo":null}' | ./dasel -r json 'foo'
null
$ echo '{"foo":null}' | ./dasel delete -r json 'foo'
{}

The fix is on master and I'll create a release shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants