File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ extension _PostgresSQLDatabase: SQLDatabase {
32
32
return try self . database. query ( sql, binds. map { encodable in
33
33
return try self . encoder. encode ( encodable)
34
34
} ) { row in
35
- onRow ( row)
35
+ onRow ( row. sqlRow ( using : self . decoder ) )
36
36
}
37
37
} catch {
38
38
return self . eventLoop. makeFailedFuture ( error)
Original file line number Diff line number Diff line change 1
- extension PostgresRow : SQLRow {
2
- public func decode< D> ( column: String , as type: D . Type ) throws -> D where D : Decodable {
3
- guard let data = self . column ( column) else {
1
+ extension PostgresRow {
2
+ public func sqlRow( using decoder: PostgresDecoder ) -> SQLRow {
3
+ return _PostgreSQLRow ( row: self , decoder: decoder)
4
+ }
5
+
6
+ public func sqlRow( using decoder: JSONDecoder = JSONDecoder ( ) ) -> SQLRow {
7
+ return _PostgreSQLRow ( row: self , decoder: PostgresDataDecoder ( jsonDecoder: decoder) )
8
+ }
9
+ }
10
+
11
+ private struct _PostgreSQLRow : SQLRow {
12
+ let row : PostgresRow
13
+ let decoder : PostgresDecoder
14
+
15
+ func decode< D> ( column: String , as type: D . Type ) throws -> D where D : Decodable {
16
+ guard let data = self . row. column ( column) else {
4
17
fatalError ( )
5
18
}
6
19
return try self . decoder. decode ( D . self, from: data)
You can’t perform that action at this time.
0 commit comments