2
0

Better error when Scan fails due to unknown destination type

fixes #31
This commit is contained in:
Jack Christensen
2014-09-02 16:58:10 -05:00
parent d28108b127
commit b8881af745
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -246,7 +246,7 @@ func (rows *Rows) Scan(dest ...interface{}) (err error) {
rows.Fatal(err)
}
default:
rows.Fatal(errors.New("Unknown type"))
rows.Fatal(fmt.Errorf("Scan cannot decode into %T", d))
}
if vr.Err() != nil {
+2
View File
@@ -439,6 +439,7 @@ func TestQueryRowErrors(t *testing.T) {
type allTypes struct {
i16 int16
i int
s string
}
@@ -455,6 +456,7 @@ func TestQueryRowErrors(t *testing.T) {
{"SYNTAX ERROR", []interface{}{}, []interface{}{&actual.i16}, "SQLSTATE 42601"},
{"select $1::text", []interface{}{"Jack"}, []interface{}{&actual.i16}, "Cannot decode oid 25 into int16"},
{"select $1::int8range", []interface{}{int(705)}, []interface{}{&actual.s}, "Cannot encode int into oid 3926 - int must implement Encoder or be converted to a string"},
{"select 42::int4", []interface{}{}, []interface{}{&actual.i}, "Scan cannot decode into *int"},
}
for i, tt := range tests {