Error while fetching Number attribute type with Null value
See original GitHub issueSummary: Error while fetching Null attribute type in DynamoDB (“rating”:{“NULL”:true}) as Number attribute in schema.
Error : Attribute “rating” of type “N” has an invalid value of {“NULL”:true}
Code sample:
Schema
const person = new Schema({ sid: { type: Number, hashKey: true }, asd: [ { ID: Number, Activities : [ { … … rating: { type:Number, required: false }, startDate: String } ] } ] });
Model
var personModel = dynamoose.model(config.schema.person, Person); var personActivities = await personModel .scan(‘sid’).eq(1).exec();
Current output and behavior:
Attribute “rating” of type “N” has an invalid value of {“NULL”:true}
Expected output and behavior:
get rating as null
Environment: dev
Operating System: windows
Operating System Version: 10
Node.js version (node -v
):v8.14.0
NPM version: (npm -v
):6.4.1
Dynamoose version:1.6.4
Dynamoose Plugins:
https://www.npmjs.com/package/dynamoose
Dynamoose Plugins:
- Yes, I believe that one or multiple 3rd party Dynamoose plugins are effecting this issue
- No, I believe this issue is independent of any 3rd party Dynamoose plugins I’m using
- Unknown, I’m unsure if Dynamoose plugins are effecting this issue
- I am not using any Dynamoose plugins
Other information (if applicable):
Type (select 1):
- Bug report
- Feature suggestion
- Question
- Other suggestion
- Something not listed here
Other:
- I have read through the Dynamoose documentation before posting this issue
- I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
- I have searched the internet and Stack Overflow to ensure this issue hasn’t been raised or answered before
- I have tested the code provided and am confident it doesn’t work as intended
- I have ensured that all of my plugins that I’m using with Dynamoose are listed above
- I have filled out all fields above
- I am running the latest version of Dynamoose
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Error while fetching Number attribute type with Null value #589
Summary: Error while fetching Null attribute type in DynamoDB ("rating":{"NULL":true}) as Number attribute in schema.
Read more >Handle null value when using strict attribute type PDO
Example : type_of is string, when the value is null so it will change into an empty string. weight is float, then it...
Read more >Solved: "Attribute ... cannot be NULL" error for optional
Solved: I'm using the import wizard for importing data, but am getting this error for some fields, even if they aren't required (they're...
Read more >Error while fetching Number attribute type with Null value
Summary: Error while fetching Null attribute type in DynamoDB ("rating":{"NULL":true}) as Number attribute in schema.
Read more >Nulls in GraphQL: Cheatsheet - Hasura
The server returns a root field called errors , from which the client can extract them, and a root field called data that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve also run into this issue. So +1 on getting a fix. Pretty sure the logic here should be that if
{required: false}
is set, to simply accept that the number is empty.Best workaround for now is overriding parser with:
I’m not opposed to adding null as a type to Dynamoose. But I’m trying to figure out real world use cases for it. As of right now I’d just add it as a type just like anything else and disallow using it in place of other defined types. Because I don’t see the practical use case for anything else. Which means the original issue of this issue would still exist.
What is the benefit of doing it over just not storing anything for that value? And what is the difference? If a value exists as null, vs an attribute in your schema that doesn’t exist in a specific item, what is the difference between those two situations from a practical standpoint? What are the differences in how they should be interpreted from a developers perspective?
The 2nd point I don’t see as being valid. You have to remain some type of control over the data. Dynamoose already throws errors for using the wrong type in your data. If you have other factors writing bad data to your database, you are gonna run into so many problems.
I need to understand more real world use cases in order to assess this.