-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgresConnection.swift
More file actions
37 lines (34 loc) · 1.02 KB
/
PostgresConnection.swift
File metadata and controls
37 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// PostgresConnection.swift
// feather-postgres-database
//
// Created by Tibor Bödecs on 2026. 01. 10..
//
import FeatherDatabase
import PostgresNIO
extension PostgresConnection: @retroactive DatabaseConnection {
/// Execute a Postgres query on this connection.
///
/// This wraps `PostgresNIO` query execution and maps errors.
/// - Parameter query: The Postgres query to execute.
/// - Throws: A `DatabaseError` if the query fails.
/// - Returns: A query result containing the returned rows.
@discardableResult
public func execute(
query: PostgresQuery
) async throws(DatabaseError) -> PostgresQueryResult {
do {
let result = try await self.query(
.init(
unsafeSQL: query.sql,
binds: query.bindings
),
logger: logger
)
return PostgresQueryResult(backingSequence: result)
}
catch {
throw DatabaseError.query(error)
}
}
}