mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Cleanup
This commit is contained in:
1 parent
87024f0426
commit
95eb9afeef
2 files changed
+8
-16
No files matched your search
@@ -153,6 +153,12 @@ extension RowAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
extension RowAdapter {
|
||||
func baseColumIndex(adaptedIndex index: Int, with statement: SelectStatement) throws -> Int {
|
||||
return try concreteRowAdapter(with: statement).concreteColumnMapping.baseColumIndex(adaptedIndex: index)
|
||||
}
|
||||
}
|
||||
|
||||
/// ColumnMapping is a row adapter that maps column names.
|
||||
///
|
||||
/// let adapter = ColumnMapping(["foo": "bar"])
|
||||
|
||||
@@ -73,14 +73,7 @@ public extension DatabaseValueConvertible where Self: StatementColumnConvertible
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchCursor(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseCursor<Self> {
|
||||
// We'll read from leftmost column at index 0, unless adapter mangles columns
|
||||
let columnIndex: Int32
|
||||
if let adapter = adapter {
|
||||
let concreteAdapter = try adapter.concreteRowAdapter(with: statement)
|
||||
columnIndex = Int32(concreteAdapter.concreteColumnMapping.baseColumIndex(adaptedIndex: 0))
|
||||
} else {
|
||||
columnIndex = 0
|
||||
}
|
||||
|
||||
let columnIndex = try Int32(adapter?.baseColumIndex(adaptedIndex: 0, with: statement) ?? 0)
|
||||
let sqliteStatement = statement.sqliteStatement
|
||||
return try statement.fetchCursor(arguments: arguments) {
|
||||
if sqlite3_column_type(sqliteStatement, columnIndex) == SQLITE_NULL {
|
||||
@@ -118,14 +111,7 @@ public extension DatabaseValueConvertible where Self: StatementColumnConvertible
|
||||
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
|
||||
public static func fetchOne(_ statement: SelectStatement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? {
|
||||
// We'll read from leftmost column at index 0, unless adapter mangles columns
|
||||
let columnIndex: Int32
|
||||
if let adapter = adapter {
|
||||
let concreteAdapter = try! adapter.concreteRowAdapter(with: statement)
|
||||
columnIndex = Int32(concreteAdapter.concreteColumnMapping.baseColumIndex(adaptedIndex: 0))
|
||||
} else {
|
||||
columnIndex = 0
|
||||
}
|
||||
|
||||
let columnIndex = try Int32(adapter?.baseColumIndex(adaptedIndex: 0, with: statement) ?? 0)
|
||||
let sqliteStatement = statement.sqliteStatement
|
||||
let cursor = try statement.fetchCursor(arguments: arguments) { () -> Self? in
|
||||
if sqlite3_column_type(sqliteStatement, columnIndex) == SQLITE_NULL {
|
||||
|
||||
Reference in new issue
Block a user