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
sqlitex.Pool.Get should never return a nil Conn — click here to learn more! #17
Comments
This API is carried over from `crawshaw.io/sqlite/sqlitex`, so I'm a bit
loathe to change the nil-ness of the return, but I'd be open to having a
nil `*sqlite.Conn` return errors. Would that address your needs?
|
Ah, you mean if all the methods did a nil check on the receiver? Yeah, Totes McGotes 👍 And if pool.Put &c. handled a nil Conn, too. |
@zombiezen Does that cover sqlitex.Exec-class functions? edit: I reckon it does, just want the explicit confirmation :) |
It should, since all of the |
conn := pool.Get(ctx)
defer pool.Put(conn) This still panics if conn is nil. |
I can't seem to re-open? lol github @zombiezen ← mentioning just in case |
Oh right, |
Right now, sqlitex.Pool.Get can return a nil Conn in a few circumstances, for example if the pool has been closed, or if the provided context has been canceled. This means consumers can't safely use the normal Get/defer Put idiom.
And instead must do an explicit nil check within each stanza.
It would be better if the Get method always returned a non-nil Conn, and, in the situations where it's not actually usable, have all of its methods short-circuit and return an appropriate error.
The text was updated successfully, but these errors were encountered: