11package com.powersync.integrations.room
22
3- import androidx.room .RoomDatabase
4- import androidx.room .Transactor
5- import androidx.room.execSQL
6- import androidx.room .useReaderConnection
7- import androidx.room .useWriterConnection
3+ import androidx.room3 .RoomDatabase
4+ import androidx.room3 .Transactor
5+ import androidx.room3.executeSQL
6+ import androidx.room3 .useReaderConnection
7+ import androidx.room3 .useWriterConnection
88import androidx.sqlite.SQLiteException
99import androidx.sqlite.SQLiteStatement
1010import com.powersync.db.driver.SQLiteConnectionLease
@@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.MutableSharedFlow
1515import kotlinx.coroutines.flow.SharedFlow
1616import kotlinx.coroutines.launch
1717import kotlinx.coroutines.runBlocking
18- import kotlinx.serialization.json.Json
1918import kotlin.coroutines.CoroutineContext
2019
2120/* *
@@ -94,7 +93,7 @@ public class RoomConnectionPool(
9493 db.useWriterConnection {
9594 if (! hasInstalledUpdateHook) {
9695 hasInstalledUpdateHook = true
97- it.execSQL (" SELECT powersync_update_hooks('install')" )
96+ it.executeSQL (" SELECT powersync_update_hooks('install')" )
9897 }
9998
10099 try {
@@ -157,14 +156,7 @@ private class RoomTransactionLease(
157156 override suspend fun <R > usePreparedAsync (
158157 sql : String ,
159158 block : suspend (SQLiteStatement ) -> R ,
160- ): R =
161- transactor.usePrepared(sql) {
162- // TODO: This is suspending in Room3, where we can avoid the runBlocking here.
163- stmt ->
164- // Don't use the context here, Room2 does that for us. We're not allowed to use the
165- // connection from different threads.
166- runBlocking { block(stmt) }
167- }
159+ ): R = transactor.usePrepared(sql, block)
168160
169161 override fun isInTransactionSync (): Boolean =
170162 runBlocking(context) {
0 commit comments