diff --git a/core/src/commonMain/kotlin/com/powersync/db/PowerSyncDatabaseImpl.kt b/core/src/commonMain/kotlin/com/powersync/db/PowerSyncDatabaseImpl.kt index f219f0ce..8a29ebeb 100644 --- a/core/src/commonMain/kotlin/com/powersync/db/PowerSyncDatabaseImpl.kt +++ b/core/src/commonMain/kotlin/com/powersync/db/PowerSyncDatabaseImpl.kt @@ -209,10 +209,6 @@ internal class PowerSyncDatabaseImpl( return internalDb.execute(sql, parameters) } - override suspend fun executeWrite(sql: String, parameters: List?): Long { - return internalDb.executeWrite(sql, parameters) - } - private suspend fun handleWriteCheckpoint(lastTransactionId: Int, writeCheckpoint: String?) { writeTransaction { internalDb.queries.deleteEntriesWithIdLessThan(lastTransactionId.toLong()) diff --git a/core/src/commonMain/kotlin/com/powersync/db/WriteQueries.kt b/core/src/commonMain/kotlin/com/powersync/db/WriteQueries.kt index 9fdca086..544c2409 100644 --- a/core/src/commonMain/kotlin/com/powersync/db/WriteQueries.kt +++ b/core/src/commonMain/kotlin/com/powersync/db/WriteQueries.kt @@ -9,8 +9,6 @@ interface WriteQueries { */ suspend fun execute(sql: String, parameters: List? = listOf()): Long - suspend fun executeWrite(sql: String, parameters: List?): Long - suspend fun writeTransaction(body: suspend SuspendingTransactionWithReturn.() -> R): R } \ No newline at end of file diff --git a/core/src/commonMain/kotlin/com/powersync/db/internal/PsInternalDatabase.kt b/core/src/commonMain/kotlin/com/powersync/db/internal/PsInternalDatabase.kt index 6d827c29..967d0468 100644 --- a/core/src/commonMain/kotlin/com/powersync/db/internal/PsInternalDatabase.kt +++ b/core/src/commonMain/kotlin/com/powersync/db/internal/PsInternalDatabase.kt @@ -51,11 +51,11 @@ class PsInternalDatabase(val driver: PsSqlDriver, private val scope: CoroutineSc ): Long { val numParams = parameters?.size ?: 0 - return createQuery( + return createWriteQuery( sql, parameters = numParams, binders = getBindersFromParams(parameters) - ).awaitAsOneOrNull() ?: 0 + ).awaitAsOneOrNull() ?: 0L } override suspend fun get( @@ -115,12 +115,21 @@ class PsInternalDatabase(val driver: PsSqlDriver, private val scope: CoroutineSc } - private fun createQuery( + private fun createWriteQuery( query: String, parameters: Int = 0, binders: (SqlPreparedStatement.() -> Unit)? = null, ): ExecutableQuery { - return createQuery(query, { cursor -> cursor.getLong(0)!! }, parameters, binders) + return object : ExecutableQuery(mapper = { cursor -> cursor.getLong(0)!! }) { + override fun execute(mapper: (SqlCursor) -> QueryResult): QueryResult { + return driver.execute( + identifier = null, + sql = query, + parameters, + binders + ) as QueryResult + } + } } private fun createQuery( @@ -167,12 +176,6 @@ class PsInternalDatabase(val driver: PsSqlDriver, private val scope: CoroutineSc return transactor.transactionWithResult(noEnclosing = true, body) } - override suspend fun executeWrite(sql: String, parameters: List?): Long { - return writeTransaction { - execute(sql, parameters) - } - } - // Register callback for table updates private fun tableUpdates(): Flow> { return driver.tableUpdates()