Skip to content

Can I use "clientDefault" with a non-nullable column? #1498

Answered by simolus3
mattsimgithub asked this question in Q&A

You must be logged in to vote

How did you manage to construct a MyClass with id: null under null safety? I would expect the generated data class to have a non-null String id field to reflect the non-nullable column.

Maybe the generated code could be a bit more friendly around clientDefault (we could potentially generate a nullable argument that defaults to the custom default otherwise). But in general, the idea is that you'd use the generated companion classes to represent partial rows. So you could use MyClassCompanion.insert to construct a companion that only requires what's necessary for inserts, all default values will be filled later.

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@mattsimgithub

Answer selected by mattsimgithub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants