Skip to content
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

ALTER table adds a default value to the new column even if the entity class doesn't have a default value #24

Open
ubarua123 opened this issue Jan 3, 2022 · 1 comment

Comments

@ubarua123
Copy link

I added this column in my entity class

@ColumnInfo(name = "show_logo_on_download")
var showLogoOnDownload : Boolean = true,

As you can see, the default value is true in the code but not at the database level.

The corresponding json file generated
show_logo_on_download INTEGER NOT NULL, ......

However the migration codegen generated
ALTER TABLE table_name ADD show_logo_on_download INTEGER NOT NULL DEFAULT 0

Now because of this, in the code, I am expecting a true for showLogoOnDownload but now it's false everywhere because the database inserted 0 as the default value.

Now as a result I have write a migration code just so that I fill it explicitly with 1 i.e., true

Can you please look into this? This library has been extremely useful to me.

@MatrixDev
Copy link
Owner

Hello @ubarua123. Library doesn't take to account anything related to the Kotlin code, it only parses json files generated by the Room library. Please check whether generated json files actually has true as a default value. If there is no default value - than type-based (not field-based) default value will be taken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants