DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Table not created on some devices (Samsung, Nexus 5X)

Open gnuhel opened this issue 10 years ago • 5 comments

DBFlow Version: 3.1.1 Issue Kind: Bug

Description: Hi, on my project I use DbFlow with Kotlin, DbFlow is cofiqured in a seperate module.

On some devices I get an exception:

Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(no such table: ...)

It seems that the table is not created. If I clear app cache then it creates correctly. It might be a Marshmallow permission issue causes the issue but it does not happen for all devices.

Does anybody also have the issue?

gnuhel avatar Oct 01 '16 10:10 gnuhel

Sounds like it could be caused by a migration issue as well. Keep in mind that dbflow will create tables that are missing then run migration scrips from current schema level to target schema level.

Make sure you don't . have any inappropriate DROP TABLE commands in any migrations

trevjonez avatar Oct 01 '16 19:10 trevjonez

I have not seen this issue on any device Ive used. Is there any more information you can provide, such as how you initialize DBFlow and how you use it.

agrosner avatar Oct 02 '16 13:10 agrosner

I inititialize DbFlow in Applicaiton

    private fun initDBFlow() {
        FlowManager.init(FlowConfig.Builder(this).build())
        FlowManager.initModule(DataGeneratedDatabaseHolder::class.java)
    }

also this does not work

    private fun initDBFlow() {
        FlowManager.init(FlowConfig.Builder(this).addDatabaseHolder(DataGeneratedDatabaseHolder.class).build());
    }

in build.gradle of data-module i have this

kapt {
    generateStubs = true
    arguments {
        arg("targetModuleName", "Data")
    }
}

here is the table

@Table(name = "SectionViewDb", database = WeltNewsDatabase.class)
public class SectionViewDb extends BaseModel {

    @PrimaryKey public String name;
    @Column public int viewCount;
    @Column public boolean noteHandled;

    @Inject
    public SectionViewDb() {
    }

    public SectionViewDb(final String name) {
        this.name = name;
    }

    public SectionView toSectionView() {
        return new SectionView(name, viewCount, noteHandled);
    }
}

gnuhel avatar Oct 05 '16 09:10 gnuhel

were you writing to external storage?

agrosner avatar Dec 04 '16 15:12 agrosner

if so you would want to initialize DBFlow after that then if it cannot create DBs.

agrosner avatar Dec 04 '16 15:12 agrosner