Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting exception on iterator #1036

Closed
avnerbarr opened this issue Dec 27, 2020 · 4 comments
Closed

getting exception on iterator #1036

avnerbarr opened this issue Dec 27, 2020 · 4 comments

Comments

@avnerbarr
Copy link

getting a crash here when the DB is open in 2 processes:

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: database is locked (code: 5)
extension FailableIterator {
    public func next() -> Element? {
        return try! failableNext()
    }
}

// when iterating
for row in try db.prepare(...) {
        }
@juanjoseluisgarcia
Copy link

SQLite blocks the file when you access it. You need to keep a global reference to the connection to avoid this kind of issues. On another matter of things, this repo is abandoned. The Author is involved in some kind of online teaching courses and even though he has activity on other repos he seems to not have the courage to announce he will not be continuing with this one. My advice is that you switch to another library like GRDB.

@nathanfallet
Copy link
Collaborator

We merged a fix replacing the try! by a try?.

@tw0po1nt
Copy link

tw0po1nt commented Jun 9, 2023

@nathanfallet I am still getting this crash on the latest release 0.14.1. It appears the try? you mention is still a try!, so this is still an issue.

@nathanfallet
Copy link
Collaborator

@tw0po1nt We reverted this fix; as explained in #1075, you should use failableNext() and handle the error by yourself using a do/catch block. We cannot provide a default behavior (e.g. return nil) when an error occurs, it's up to you to choose what you want to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants