Skip to content

Commit 40a4ed5

Browse files
committed
Refactored "insert" and "compileStatement"
Changed "insert" to directly compile the mapped sql instead of creating a "MappingSupportSQLiteStatement" Added check if the database is open to "compileStatement" *This commit is related to issue #529 [1]* [1] #529
1 parent cfde324 commit 40a4ed5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎data/src/main/java/org/cryptomator/data/db/sqlmapping/MappingSupportSQLiteDatabase.kt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ internal class MappingSupportSQLiteDatabase(
4848
throw SQLiteException("Invalid conflict algorithm")
4949
}
5050
val processed = helper.insertWithOnConflict(table, null, values, conflictAlgorithm)
51-
val statement = MappingSupportSQLiteStatement(processed.sql)
51+
val statement = delegate.compileStatement(map(processed.sql))
5252
SimpleSQLiteQuery.bind(statement, processed.bindArgs)
5353

54-
return statement.executeInsert()
54+
return statement.use { it.executeInsert() }
5555
}
5656

5757
override fun update(
@@ -73,6 +73,9 @@ internal class MappingSupportSQLiteDatabase(
7373
}
7474

7575
override fun compileStatement(sql: String): SupportSQLiteStatement {
76+
if(!isOpen) {
77+
throw SQLiteException("Database already closed")
78+
}
7679
return MappingSupportSQLiteStatement(sql)
7780
}
7881

0 commit comments

Comments
 (0)