question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use of default values for case class fields if dynamodb field is missing

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tolomauscommented, Jan 31, 2019

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 😉

0reactions
regiskuckaertzcommented, Jun 8, 2019

Closing as M10 provides DynamoValue which allows easier manual derivation.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found