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

Null values are unable to be processed in Iter #26

Open
rhett-panter opened this issue Mar 14, 2017 · 4 comments
Open

Null values are unable to be processed in Iter #26

rhett-panter opened this issue Mar 14, 2017 · 4 comments

Comments

@rhett-panter
Copy link

rhett-panter commented Mar 14, 2017

Error: dynamo: unmarshal int: expected N to be non-nil

using struct with
varname int dynamo:"varname,omitempty"

Dynamo search shows "varname Null : true" when using "Iter.Next(&struct)"

I'm not finding a way to continue without this failing out.

@guregu
Copy link
Owner

guregu commented Mar 14, 2017

omitempty works best when you don't set the attributes instead of setting them to null. I think I can fix this issue though, thanks for the report.

@rhett-panter
Copy link
Author

rhett-panter commented Mar 14, 2017

Awesome, I just haven't been able to find a way around the issue so I thought I would report it just in case it was an issue. Thank you!

@guregu
Copy link
Owner

guregu commented Mar 14, 2017

In the meantime, if you use a pointer for your int, like:

type Widget struct {
	Number *int `dynamo:"number"`
}

it might help.

However right now there is no way to encode a null value, it just gets omitted whether you specify omitempty or not, just like empty strings. This was kind of a personal preference. I think it's best to avoid using the null type in DynamoDB altogether but I understand that people may have preexisting data. Maybe I'll provide a way to configure this.

@guregu
Copy link
Owner

guregu commented Apr 5, 2017

It's hard to fix this easily with the current decoding code, but it's possible. I think this is worth fixing because of how the official encoding/decoding libraries work. See also #28.

The origin of this bug is a difference of philosophies between AWS and me regarding empty strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants