Skip to content

Commit

Permalink
Always reset transaction after modifying DB
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Feb 6, 2025
1 parent e95463a commit 573c05e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,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 @@ -338,7 +338,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 573c05e

Please sign in to comment.