stephencelis / SQLite.swift

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

Always start the iterator at the same location #1002

Closed gsabran closed 4 years ago

gsabran commented 4 years ago

I was looking at a crash that happens when statement.next() is called. I have not gotten to the bottom of it, but I came across this code that doesn't seem to do what it intends. Indeed it seems that calling the iterator several time will not do the same thing:

let result = self.db.prepare(query)
result.forEach { ... }
// The second call will loop over the rows from a different element?
result.forEach { ... }
gsabran commented 4 years ago

Next is actually called from within iterator, not when creating it. I got confused.