diff --git a/Sources/SQLite/Core/Statement.swift b/Sources/SQLite/Core/Statement.swift index 6cb2e5d3..465a441c 100644 --- a/Sources/SQLite/Core/Statement.swift +++ b/Sources/SQLite/Core/Statement.swift @@ -214,8 +214,8 @@ public protocol FailableIterator: IteratorProtocol { extension FailableIterator { public func next() -> Element? { - // swiftlint:disable:next force_try - try! failableNext() + // Do not force try + try? failableNext() } } diff --git a/Sources/SQLite/Typed/Query.swift b/Sources/SQLite/Typed/Query.swift index 2a83665c..b5d11ac2 100644 --- a/Sources/SQLite/Typed/Query.swift +++ b/Sources/SQLite/Typed/Query.swift @@ -1009,10 +1009,9 @@ extension Connection { let statement = try prepare(expression.template, expression.bindings) let columnNames = try columnNamesForQuery(query) + let rows = try statement.failableNext().map { Row(columnNames, $0) } - return AnySequence { - AnyIterator { statement.next().map { Row(columnNames, $0) } } - } + return AnySequence { AnyIterator { rows } } } public func prepareRowIterator(_ query: QueryType) throws -> RowIterator {