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: *Rows.Err() does not return errors from *Rows.Scan() #25787

Open
zombiezen opened this issue Jun 7, 2018 · 4 comments
Open

database/sql: *Rows.Err() does not return errors from *Rows.Scan() #25787

zombiezen opened this issue Jun 7, 2018 · 4 comments

Comments

@zombiezen
Copy link
Contributor

@zombiezen zombiezen commented Jun 7, 2018

I'm not really advocating for the behavior to change, but the usage of the word "iteration" in the current documentation of Rows.Err() is ambiguous with respect to the behavior of *Rows.Scan(). More examples and/or more precise documentation would help.

What version of Go are you using (go version)?

go version go1.10.2 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

https://play.golang.org/p/1xbP8gEMNtb

What did you expect to see?

(Given a certain reading of the Rows.Err() docs:)

2018/06/07 10:24:45 Error from Scan(...): sql: Scan error on column index 0: sql/driver: couldn't convert 42 into type bool
2018/06/07 10:24:45 Error from Err(): sql: Scan error on column index 0: sql/driver: couldn't convert 42 into type bool

What did you see instead?

2018/06/07 10:24:45 Error from Scan(...): sql: Scan error on column index 0: sql/driver: couldn't convert 42 into type bool
2018/06/07 10:24:45 No error from Err()
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Jun 7, 2018

CC @bradfitz @kardianos for SQL, @robpike for prose

@bcmills bcmills added this to the Unplanned milestone Jun 7, 2018
@kardianos

This comment has been minimized.

Copy link
Contributor

@kardianos kardianos commented Jun 7, 2018

There is a change on master that may address this. Scan should return errs now if rows.lasterr == nil.
Does this help?

@kardianos

This comment has been minimized.

Copy link
Contributor

@kardianos kardianos commented Jun 7, 2018

Oh wait, you want the opposite. You would like Scan to store the scan error in lasterr if lasterr is nil so it can get reported in rows.Err().

@bcmills bcmills removed the WaitingForInfo label Jun 7, 2018
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Jun 7, 2018

Yep. It's not obvious that the phrase “during iteration” is intended to exclude Scan, since the Scan call occurs after the start of iteration and before the end.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.