Navigation Menu

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
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@zombiezen
Copy link
Contributor

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 bcmills added Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 7, 2018
@bcmills
Copy link
Contributor

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
Copy link
Contributor

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

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 7, 2018
@kardianos
Copy link
Contributor

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 Issue is not actionable because of missing required information, which needs to be provided. label Jun 7, 2018
@bcmills
Copy link
Contributor

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
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants