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

IllegalStateException: Cannot perform this operation because there is no current transaction #1719

Open
royorange opened this issue Mar 29, 2021 · 1 comment

Comments

@royorange
Copy link

royorange commented Mar 29, 2021

DBFlow Version: 4.2.4

Bug or Feature Request: Runtime exception

Description:
The lib works well, but I found some crash issue from users after a migration.
The online log collected the exception, here is the stacktrace:

Caused by: java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
	at android.database.sqlite.SQLiteSession.throwIfNoTransaction(SQLiteSession.java:937)
	at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:410)
	at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:611)
	at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:442)
	at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:332)
	at com.raizlabs.android.dbflow.structure.database.FlowSQLiteOpenHelper.getDatabase(FlowSQLiteOpenHelper.java:62)
	at com.raizlabs.android.dbflow.config.DatabaseDefinition.getWritableDatabase(DatabaseDefinition.java:257)
	at com.raizlabs.android.dbflow.sql.queriable.ModelLoader.load(ModelLoader.java:36)
	at com.raizlabs.android.dbflow.sql.queriable.ListModelLoader.load(ListModelLoader.java:25)
	at com.raizlabs.android.dbflow.sql.language.BaseModelQueriable.queryList(BaseModelQueriable.java:61)
	at com.raizlabs.android.dbflow.sql.language.Where.queryList(Where.java:236)

The migration is about change the primary key of one table, and everything works well during the test.
the migration sql file is:

drop table SearchData;
create table SearchData
(
  text              TEXT,
  url               TEXT,
  updateDate        INTEGER,
  primary key(text)
);
COMMIT;

How can I fix it?
Thanks

@royorange
Copy link
Author

royorange commented Mar 29, 2021

It looks like something wrong in the FlowSQLiteOpenHelper.onUpgrade method?

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

1 participant