stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.59k stars 1.55k forks source link

Add a new method to capture errors during the iteration #1027

Closed gsabran closed 2 years ago

gsabran commented 3 years ago

The iterator returned by prepare would crash during iteration when it encounters an error at

https://github.com/stephencelis/SQLite.swift/blob/210098546d59678f720e4ef67f8b562acfebbdb0/Sources/SQLite/Core/Statement.swift#L211

This PR proposes a change to add a method to load all of the query's results at once, safely catching possible errors.

nathanfallet commented 2 years ago

@gsabran I merged #1030, does it fix the problem or this PR needs to be merged as well? (because it is related)

jberkel commented 2 years ago

the suggested change is problematic for large queries (memory)

jberkel commented 2 years ago

actually this is already possible with the RowIterator API:

let result = try Array(db.prepareRowIterator(users))
gsabran commented 2 years ago

thanks