diff --git a/query.go b/query.go index d6c73e20..2be37797 100644 --- a/query.go +++ b/query.go @@ -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 { diff --git a/query_test.go b/query_test.go index 439d808a..f43a66e1 100644 --- a/query_test.go +++ b/query_test.go @@ -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 {