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

Fix saveUnknown throwing errors when value where falsy #336

Merged
merged 2 commits into from
Jun 11, 2018
Merged

Fix saveUnknown throwing errors when value where falsy #336

merged 2 commits into from
Jun 11, 2018

Conversation

jonathonlui
Copy link
Contributor

@jonathonlui jonathonlui commented Apr 11, 2018

When a model has saveUnknown=true and trying to save the model with an unknown attribute with 0 or false values was causing Attribute.setTypeFromRawValue to throw a SchemaError.

I remove the value check from setTypeFromRawValue, which I assume was unnecessarily copied from setType. This allows 0 and false to be correctly converted to dynamo types.

Attributes with the other falsy values like are null, undefined, or 'NaN' are now excluded because it was causing new Attribute to throw TypeError at https://github.com/automategreen/dynamoose/blob/35deac2aaaa418f01b37d9bf8427626a22d142d7/lib/Attribute.js#L12

Also fix the NewModel name test to include missing suffix.

Copy link
Member

@fishcharlie fishcharlie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fishcharlie
Copy link
Member

Going to keep this open for a bit, just to make sure no one has any other thoughts, and to time this with the release of Dynamoose 0.9. We'll for sure try to get this into version 0.9.

And thank you so much for this!

@fishcharlie fishcharlie merged commit fe9bda5 into dynamoose:master Jun 11, 2018
@fishcharlie fishcharlie modified the milestones: v0.9.0, v1.0 Jun 13, 2018
@fishcharlie fishcharlie mentioned this pull request Jun 13, 2018
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

Successfully merging this pull request may close these issues.

3 participants