stephencelis/SQLite.swift

assertionFailure happened in iterator

phuanggh opened this issue · 0 comments

version: 0.15.2

a crash happened at AnyIterator { statement.next().map { Row(columnNames, $0) } } in Query.swift

public func prepare(_ query: QueryType) throws -> AnySequence<Row> {
        let expression = query.expression
        let statement = try prepare(expression.template, expression.bindings)

        let columnNames = try columnNamesForQuery(query)

        return AnySequence {
            AnyIterator { statement.next().map { Row(columnNames, $0) } }
        }
    }

I saw #1075 but am unsure how I am supposed to handle errors using failableNext directly.
I used a do-catch block for this func prepare(_: ) but this didn't prevent the crash from happening