You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, the generated data classes are meant to hold a full row, as it appears in the table, so all non-nullable fields will be @required, even if they have default values.
When you only want to insert or update some of the columns (e.g. use the default / auto-increment values for everything else), you can use the generated Companion classes (see the changelog at 1.5 for details). Here's an example where the id would be required but is omitted because of the default value: https://github.com/simolus3/moor/blob/01db5e2afcaf206782307c4d307389c4b54d1428/moor_flutter/example/lib/bloc.dart#L63-L66
Introducing another class might seem unnecessarily complicated at first, but allows us to cleanly separate between "I want to set this column to null when inserting" and "I want to use the default value", which we couldn't do by implicitly setting the field to null.
I'm closing this for now, but please feel free to reply if you have any more questions.
No description provided.
The text was updated successfully, but these errors were encountered: