File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -91,10 +91,26 @@ public struct MySQLConnectionSource: ConnectionPoolSource {
91
91
92
92
extension MySQLConnection : ConnectionPoolItem { }
93
93
94
+ struct MissingColumn : Error {
95
+ let column : String
96
+ }
97
+
94
98
extension MySQLRow : SQLRow {
99
+ public var allColumns : [ String ] {
100
+ self . columnDefinitions. map { $0. name }
101
+ }
102
+
103
+ public func contains( column: String ) -> Bool {
104
+ self . columnDefinitions. contains { $0. name == column }
105
+ }
106
+
107
+ public func decodeNil( column: String ) throws -> Bool {
108
+ self . column ( column) == nil
109
+ }
110
+
95
111
public func decode< D> ( column: String , as type: D . Type ) throws -> D where D : Decodable {
96
112
guard let data = self . column ( column) else {
97
- fatalError ( )
113
+ throw MissingColumn ( column : column )
98
114
}
99
115
return try MySQLDataDecoder ( ) . decode ( D . self, from: data)
100
116
}
You can’t perform that action at this time.
0 commit comments