Use of default values for case class fields if dynamodb field is missing
See original GitHub issueHi,
First of all many thanks for building and maintaining a library that makes my life easier 😃
I was wondering how you tackle the challenge where you need to add a new (optional) field with a default value to your case class/dynamodb table.
if I add it as an Option to my case class:
case class Farmer(name: String, age: Long, isFriendly: Boolean = true) // added isFriendly
it’s complaining about a missing when I get an already existing record from the database.
I could add the field as an explicit Option[Boolean]
but that means that I have to write more ceremony in my code base to get at my field.
Should I create my own custom DynamoFormat and explicitly set the default value for the missing field?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Working with items and attributes - Amazon DynamoDB
The default value for ReturnValues is NONE , meaning that DynamoDB does not return any information about attributes that were modified.
Read more >How to set default value of a new attribute for earlier items in ...
As a solution to this I want to use a default value for all entries with currently no value for creationDate. How do...
Read more >DynamoDB Enhanced Client for Java: Missing Setters Cause ...
Solution. Make sure every DynamoDB attribute on your entity has a publicly-accessible setter with the same name (case-sensitive) as the getter.
Read more >Basic Tutorial — PynamoDB 6.0a0 documentation
Defining Model Attributes¶ · null=True to the constructor of the attribute. When you make an attribute nullable, PynamoDB will omit that value if...
Read more >[Solved] could not unconvert attribute dynamodb - Dynobase
So, you will run into this error if the mapper class is missing a No-Arg constructor or has invalid Setters/Getters that do not...
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 Free
Top 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
Ah nice, thanks for the example code, really appreciated!
Probably a bit calmer here - politically speaking - than at your side right night, although I don’t think we’re that far off 😉
Closing as M10 provides
DynamoValue
which allows easier manual derivation.