Can I use "clientDefault" with a non-nullable column? #1498
-
Since migrating my moor files to null safe 2.12, I have a number of id columns that are non-nullable, but which are trying to use clientDefault to set a uuid:
When I try to run the app with the new non-nullable columns, I get the following exception (truncated):
I'd have preferred to have clientDefault trigger before this validation, but it seems to happen later. In my case, it wouldn't be a big deal to set the id with a uuid manually, prior to the insert, but before I get to doing this, I'd like to make sure I'm not missing a trick. Any thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
How did you manage to construct a Maybe the generated code could be a bit more friendly around |
Beta Was this translation helpful? Give feedback.
How did you manage to construct a
MyClass
withid: null
under null safety? I would expect the generated data class to have a non-nullString 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 useMyClassCompanion.insert
to construct a companion that only requires what's necessary for inserts, all default values will be filled later.