File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ extension PreparedStatement {
4545 while let row = try row() {
4646 df.appendEmptyRow()
4747 for index in (0..<columnCount) {
48- if let value = row[ index] {
48+ if let value = row.value(at: index) {
4949 df.rows[count][index] = valueTransformers[index].transform(value)
5050 }
5151 }
Original file line number Diff line number Diff line change @@ -205,17 +205,28 @@ extension PreparedStatement {
205205 let statement: PreparedStatement
206206
207207 public subscript(dynamicMember name: String) -> Value? {
208- self[ name]
208+ value(for: name)
209209 }
210210
211211 public subscript(columnName: String) -> Value? {
212- statement.columnIndexByName[columnName].flatMap { self[$0] }
212+ value(for: columnName)
213213 }
214214
215215 public subscript(columnIndex: Int) -> Value? {
216216 statement.value(at: columnIndex)
217217 }
218218
219+ public func value(for columnName: String) -> Value? {
220+ guard let columnIndex = statement.columnIndexByName[columnName] else {
221+ return nil
222+ }
223+ return value(at: columnIndex)
224+ }
225+
226+ public func value(at columnIndex: Int) -> Value? {
227+ statement.value(at: columnIndex)
228+ }
229+
219230 public func decode<T>(_ type: T.Type, using decoder: RowDecoder? = nil) throws -> T where T: Decodable {
220231 try (decoder ?? RowDecoder.default).decode(type, from: self)
221232 }
You can’t perform that action at this time.
0 commit comments