-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for defaultValue in @ColumnInfo #256
Comments
Hi! What's your exact use case for this? |
@vitusortner In Room, if defaultValue is defined, we don't have to set this property.
It is an useful feature. Because of the lack of the defaultValue property, we need to do:
|
Why not assign a default value in the class description by changing
to @ColumnInfo(name: "IsActive")
bool active=false; ? |
@mqus having non final fields isn't something I usualy do unless really needed |
Sorry, you had no What about @ColumnInfo(name: "IsActive")
final bool active;
YourClass(this.id, this.foo, {this.bar, this.active=false}); ? |
Tbh, If I would implement this, I would probably do it in the same manner as room had done it, Meaning that the generated |
Seizing the opportunity of this thread. Could I create a default value as the output a query: @ColumnInfo(name: "timestampId", defaultValue: SELECT strftime('%s', 'now') || (last_insert_rowid()+1)) I know It's a little tricky but It's all I need . May I can do it making an alter table onCreate event. However if I can do it as a default value will be much more clear. 👍 |
As I wrote before, building a I think we can accept contributions for the [1] You would have to decide at runtime(slow, for each entity separately) if you want to add single columns to the database or not. Now, the main issue is, when do you omit the columns? when the value is null? What about fields that are nullable even in the database? sqlite makes a difference between inserting |
Contributions for |
Hello, Any news about ColumnInfo.defaultValue? |
Yes this feature is welcome indeed, as we might send the .db file to other system to implement. I hope we can have this feature soon. |
Any update about this? We are in 2024 |
No description provided.
The text was updated successfully, but these errors were encountered: