Skip to content

Commit c0d27c9

Browse files
Fix withAllConnections issue
1 parent 91d48b9 commit c0d27c9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/PowerSync/Kotlin/KotlinSQLiteConnectionPool.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ final class SwiftSQLiteConnectionPoolAdapter: PowerSyncKotlin.SwiftPoolAdapter {
7171
// We currently only use this for schema updates
7272
return try await wrapExceptions {
7373
let sendableCallback = SendableAllLeaseCallback(callback)
74-
try await pool.write { lease in
74+
try await pool.withAllConnections { writer, readers in
7575
try sendableCallback.execute(
7676
writeLease: KotlinLeaseAdapter(
77-
lease: lease
77+
lease: writer
7878
),
79-
readLeases: []
79+
readLeases: readers.map { KotlinLeaseAdapter(lease: $0) }
8080
)
8181
}
8282
}

Sources/PowerSyncGRDB/Connections/GRDBConnectionPool.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ actor GRDBConnectionPool: SQLiteConnectionPoolProtocol {
6363
GRDBConnectionLease(database: database)
6464
)
6565
}
66-
66+
6767
return sessionResult
6868
}
6969
// Notify PowerSync of these changes
7070
tableUpdatesContinuation?.yield(result.affectedTables)
7171
// Notify GRDB, this needs to be a write (transaction)
72-
try await pool.write { database in
72+
try await pool.write { database in
7373
// Notify GRDB about these changes
7474
for table in result.affectedTables {
7575
try database.notifyChanges(in: Table(table))
7676
}
7777
}
7878

79-
if case .failure(let error) = result.blockResult {
79+
if case let .failure(error) = result.blockResult {
8080
throw error
8181
}
8282
}
@@ -85,7 +85,7 @@ actor GRDBConnectionPool: SQLiteConnectionPoolProtocol {
8585
onConnection: @Sendable @escaping (SQLiteConnectionLease, [SQLiteConnectionLease]) throws -> Void
8686
) async throws {
8787
// FIXME, we currently don't support updating the schema
88-
try await pool.write { database in
88+
try await pool.writeWithoutTransaction { database in
8989
let lease = try GRDBConnectionLease(database: database)
9090
try onConnection(lease, [])
9191
}

0 commit comments

Comments
 (0)