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

database/sql: Stmt.Close discards error #12798

Closed
iangudger opened this issue Sep 30, 2015 · 2 comments
Closed

database/sql: Stmt.Close discards error #12798

iangudger opened this issue Sep 30, 2015 · 2 comments
Milestone

Comments

@iangudger
Copy link
Contributor

The Stmt.Close() function in database/sql discards any error generated by the Close() function of the contained driverStmt. I think this error should be propagated.
https://github.com/golang/go/blob/master/src/database/sql/sql.go#L1579

This is preventing github.com/DATA-DOG/go-sqlmock/ExpectedPrepare.WillReturnCloseError from functioning:
DATA-DOG/go-sqlmock#25

@ianlancetaylor ianlancetaylor changed the title database/sql/Stmt.Close() discards error database/sql: Stmt.Close discards error Sep 30, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Sep 30, 2015
@iangudger
Copy link
Contributor Author

I have sent a change that addresses this issue. Please take a look.

@gopherbot
Copy link

CL https://golang.org/cl/15178 mentions this issue.

freeformz pushed a commit to lib/pq that referenced this issue Oct 15, 2015
This change is causing breakage on tip:
golang/go#12798

I think it's a reasonable upstream change.

Looking at the commit that added the code that is failing on our side
the lack of error propagation is called out and is the reason we're now
failing.
72f8451

This change attempts to preserve old behavior while supporting the fact
that errors are now propagated properly by Stmt.Close().

Open to better ways to do this though.
@golang golang locked and limited conversation to collaborators Oct 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants