Skip to content

Commit

Permalink
Merge pull request #6589 from seadowg/modify-db
Browse files Browse the repository at this point in the history
Always reset transaction after modifying DB
  • Loading branch information
lognaturel authored Feb 7, 2025
2 parents 256e017 + 84b4957 commit d3f95e1
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,15 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep
* function, but that's not available in all the supported versions of Android.
*/
private fun updateRowIdTables() {
databaseConnection.withConnection {
databaseConnection.resetTransaction {
getLists().forEach {
writableDatabase.execSQL(
execSQL(
"""
DROP TABLE IF EXISTS "${getRowIdTableName(it)}";
""".trimIndent()
)

writableDatabase.execSQL(
execSQL(
"""
CREATE TABLE "${getRowIdTableName(it)}" AS SELECT _id FROM "$it" ORDER BY _id;
""".trimIndent()
Expand All @@ -329,7 +329,7 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep
}

private fun createList(list: String) {
databaseConnection.transaction {
databaseConnection.resetTransaction {
val contentValues = ContentValues()
contentValues.put(ListsTable.COLUMN_NAME, list)
insertOrThrow(
Expand Down

0 comments on commit d3f95e1

Please sign in to comment.