Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SQLyra/DataFrame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension PreparedStatement {
while let row = try row() {
df.appendEmptyRow()
for index in (0..<columnCount) {
if let value = row[index] {
if let value = row.value(at: index) {
df.rows[count][index] = valueTransformers[index].transform(value)
}
}
Expand Down
15 changes: 13 additions & 2 deletions Sources/SQLyra/PreparedStatement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,28 @@ extension PreparedStatement {
let statement: PreparedStatement

public subscript(dynamicMember name: String) -> Value? {
self[name]
value(for: name)
}

public subscript(columnName: String) -> Value? {
statement.columnIndexByName[columnName].flatMap { self[$0] }
value(for: columnName)
}

public subscript(columnIndex: Int) -> Value? {
statement.value(at: columnIndex)
}

public func value(for columnName: String) -> Value? {
guard let columnIndex = statement.columnIndexByName[columnName] else {
return nil
}
return value(at: columnIndex)
}

public func value(at columnIndex: Int) -> Value? {
statement.value(at: columnIndex)
}

public func decode<T>(_ type: T.Type, using decoder: RowDecoder? = nil) throws -> T where T: Decodable {
try (decoder ?? RowDecoder.default).decode(type, from: self)
}
Expand Down