database/sql: update the conversion errors to be clearer

There was some ambiguity over which argument was referred to when
a conversion error was returned. Now refer to the argument by
either explicit ordinal position or name if present.

Fixes #15676

Change-Id: Id933196b7e648baa664f4121fa3fb1b07b3c4880
Reviewed-on: https://go-review.googlesource.com/31262
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Daniel Theophanes 2016-10-17 09:28:06 -07:00 committed by Brad Fitzpatrick
parent 930ab0afd7
commit 325c2aa5b6
2 changed files with 23 additions and 14 deletions

View file

@ -745,8 +745,8 @@ func TestExec(t *testing.T) {
{[]interface{}{7, 9}, ""},
// Invalid conversions:
{[]interface{}{"Brad", int64(0xFFFFFFFF)}, "sql: converting argument #1's type: sql/driver: value 4294967295 overflows int32"},
{[]interface{}{"Brad", "strconv fail"}, "sql: converting argument #1's type: sql/driver: value \"strconv fail\" can't be converted to int32"},
{[]interface{}{"Brad", int64(0xFFFFFFFF)}, "sql: converting argument $2 type: sql/driver: value 4294967295 overflows int32"},
{[]interface{}{"Brad", "strconv fail"}, `sql: converting argument $2 type: sql/driver: value "strconv fail" can't be converted to int32`},
// Wrong number of args:
{[]interface{}{}, "sql: expected 2 arguments, got 0"},