Skip to content

Commit

Permalink
Refactored "insert" and "compileStatement"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JaniruTEC committed Apr 22, 2024
1 parent cfde324 commit 40a4ed5
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ internal class MappingSupportSQLiteDatabase(
throw SQLiteException("Invalid conflict algorithm")
}
val processed = helper.insertWithOnConflict(table, null, values, conflictAlgorithm)
val statement = MappingSupportSQLiteStatement(processed.sql)
val statement = delegate.compileStatement(map(processed.sql))
SimpleSQLiteQuery.bind(statement, processed.bindArgs)

return statement.executeInsert()
return statement.use { it.executeInsert() }
}

override fun update(
Expand All @@ -73,6 +73,9 @@ internal class MappingSupportSQLiteDatabase(
}

override fun compileStatement(sql: String): SupportSQLiteStatement {
if(!isOpen) {
throw SQLiteException("Database already closed")
}
return MappingSupportSQLiteStatement(sql)
}

Expand Down

0 comments on commit 40a4ed5

Please sign in to comment.