diff options
| author | HaraldNordgren <haraldnordgren@gmail.com> | 2018-01-07 15:08:59 +0100 |
|---|---|---|
| committer | Daniel Theophanes <kardianos@gmail.com> | 2018-02-13 21:24:53 +0000 |
| commit | 8da7706bb4dc609689fd69e196ddaa800908c31f (patch) | |
| tree | 3d81ec8fcb5b40c6005e4f38013eeabaa0f7f637 /src/database/sql/sql.go | |
| parent | c0b248c234e0a5e26d7dff77adf9a9f2a92a7a9c (diff) | |
| download | go-8da7706bb4dc609689fd69e196ddaa800908c31f.tar.xz | |
database/sql: include SQL column name in Scan() error message
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 index 0, name "some_column": ...
Fixes #23362
Change-Id: I0fe71ff3c25f4c0dd9fc6aa2c2da2360dd93e3e0
Reviewed-on: https://go-review.googlesource.com/86537
Reviewed-by: Harald Nordgren <haraldnordgren@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/database/sql/sql.go')
| -rw-r--r-- | src/database/sql/sql.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 8f5588ed26..a6fa153d94 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -2885,7 +2885,7 @@ func (rs *Rows) Scan(dest ...interface{}) error { for i, sv := range rs.lastcols { err := convertAssign(dest[i], sv) if err != nil { - return fmt.Errorf("sql: Scan error on column index %d: %v", i, err) + return fmt.Errorf(`sql: Scan error on column index %d, name %q: %v`, i, rs.rowsi.Columns()[i], err) } } return nil |
