@@ -308,17 +308,15 @@ public final class PostgresClient: Sendable, ServiceLifecycle.Service {
308308 return try await closure ( lease. connection)
309309 }
310310
311- #if compiler(>=6.0)
312311 /// Lease a connection for the provided `closure`'s lifetime.
313312 ///
314313 /// - Parameter closure: A closure that uses the passed `PostgresConnection`. The closure **must not** capture
315314 /// the provided `PostgresConnection`.
316315 /// - Returns: The closure's return value.
317316 public func withConnection< Result> (
318317 isolation: isolated ( any Actor ) ? = #isolation,
319- // DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
320- // https://github.com/swiftlang/swift/issues/79285
321- _ closure: ( PostgresConnection ) async throws -> sending Result) async throws -> sending Result {
318+ _ closure: ( PostgresConnection ) async throws -> sending Result
319+ ) async throws -> sending Result {
322320 let lease = try await self . leaseConnection ( )
323321
324322 defer { lease. release ( ) }
@@ -346,41 +344,13 @@ public final class PostgresClient: Sendable, ServiceLifecycle.Service {
346344 file: String = #file,
347345 line: Int = #line,
348346 isolation: isolated ( any Actor ) ? = #isolation,
349- // DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
350- // https://github.com/swiftlang/swift/issues/79285
351- _ closure : ( PostgresConnection ) async throws -> sending Result ) async throws -> sending Result {
352- try await self . withConnection { connection in
353- try await connection. withTransaction ( logger: logger, file: file, line: line, closure)
347+ _ closure : ( PostgresConnection ) async throws -> sending Result
348+ ) async throws -> sending Result {
349+ // for 6.0 to compile we need to explicitly forward the isolation.
350+ try await self . withConnection ( isolation : isolation ) { connection in
351+ try await connection. withTransaction ( logger: logger, file: file, line: line, isolation : isolation , closure)
354352 }
355353 }
356- #else
357-
358- /// Lease a connection, which is in an open transaction state, for the provided `closure`'s lifetime.
359- ///
360- /// The function leases a connection from the underlying connection pool and starts a transaction by running a `BEGIN`
361- /// query on the leased connection against the database. It then lends the connection to the user provided closure.
362- /// The user can then modify the database as they wish. If the user provided closure returns successfully, the function
363- /// will attempt to commit the changes by running a `COMMIT` query against the database. If the user provided closure
364- /// throws an error, the function will attempt to rollback the changes made within the closure.
365- ///
366- /// - Parameters:
367- /// - logger: The `Logger` to log into for the transaction.
368- /// - file: The file, the transaction was started in. Used for better error reporting.
369- /// - line: The line, the transaction was started in. Used for better error reporting.
370- /// - closure: The user provided code to modify the database. Use the provided connection to run queries.
371- /// The connection must stay in the transaction mode. Otherwise this method will throw!
372- /// - Returns: The closure's return value.
373- public func withTransaction< Result> (
374- logger: Logger ,
375- file: String = #file,
376- line: Int = #line,
377- _ closure: ( PostgresConnection ) async throws -> Result
378- ) async throws -> Result {
379- try await self . withConnection { connection in
380- try await connection. withTransaction ( logger: logger, file: file, line: line, closure)
381- }
382- }
383- #endif
384354
385355 /// Run a query on the Postgres server the client is connected to.
386356 ///
0 commit comments