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: include SQL column name in Scan() error message #23362

Closed
HaraldNordgren opened this issue Jan 7, 2018 · 1 comment
Closed

database/sql: include SQL column name in Scan() error message #23362

HaraldNordgren opened this issue Jan 7, 2018 · 1 comment

Comments

@HaraldNordgren
Copy link
Member

@HaraldNordgren HaraldNordgren commented Jan 7, 2018

Please answer these questions before submitting your issue. Thanks!

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

My local installation is 1.8.3, but I verified that the behavior exists on master on https://go.googlesource.com/go as well.

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

Darwin 64-bit

What did you expect to see?

I want the Scan() error message to include the SQL column name, instead of just the numerical index.

The index is not always helpful -- especially when there are lots of columns in the query -- so extract the underlying column name and include that in the error string instead.

HaraldNordgren added a commit to HaraldNordgren/go that referenced this issue Jan 7, 2018
When 'convertAssign' gives an error, instead of giving just the index of
the failing column -- which is not always helpful, especially when there
are lots of columns in the query -- utilize 'rs.rowsi.Columns()' to
extract the underlying column name and include that in the error string:

    sql: Scan error on column 'name': ...

Fixes golang#23362

Change-Id: I0fe71ff3c25f4c0dd9fc6aa2c2da2360dd93e3e0
@gopherbot
Copy link

@gopherbot gopherbot commented Jan 7, 2018

Change https://golang.org/cl/86537 mentions this issue: database/sql: include SQL column name in Scan() error message

HaraldNordgren added a commit to HaraldNordgren/go that referenced this issue Jan 7, 2018
When 'convertAssign' gives an error, instead of giving just the index of
the failing column -- which is not always helpful, especially when there
are lots of columns in the query -- utilize 'rs.rowsi.Columns()' to
extract the underlying column name and include that in the error string:

    sql: Scan error on column 'name': ...

Fixes golang#23362

Change-Id: I0fe71ff3c25f4c0dd9fc6aa2c2da2360dd93e3e0
HaraldNordgren added a commit to HaraldNordgren/go that referenced this issue Jan 7, 2018
When 'convertAssign' gives an error, instead of giving just the index of
the failing column -- which is not always helpful, especially when there
are lots of columns in the query -- utilize 'rs.rowsi.Columns()' to
extract the underlying column name and include that in the error string:

    sql: Scan error on column 'name': ...

Fixes golang#23362

Change-Id: I0fe71ff3c25f4c0dd9fc6aa2c2da2360dd93e3e0
HaraldNordgren added a commit to HaraldNordgren/go that referenced this issue Jan 7, 2018
When 'convertAssign' gives an error, instead of giving just the index of
the failing column -- which is not always helpful, especially when there
are lots of columns in the query -- utilize 'rs.rowsi.Columns()' to
extract the underlying column name and include that in the error string:

    sql: Scan error on column "name": ...

Fixes golang#23362

Change-Id: I0fe71ff3c25f4c0dd9fc6aa2c2da2360dd93e3e0
@gopherbot gopherbot closed this in 8da7706 Feb 13, 2018
@golang golang locked and limited conversation to collaborators Feb 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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