2
0

Handle Scanning null into core types

Return error instead of panic.
This commit is contained in:
Jack Christensen
2014-07-12 22:07:21 -05:00
parent 5dace165f5
commit a12b7ed6c1
2 changed files with 63 additions and 0 deletions
+9
View File
@@ -408,6 +408,15 @@ func TestQueryRowCoreTypes(t *testing.T) {
}
ensureConnValid(t, conn)
// Check that Scan errors when a core type is null
err = conn.QueryRow(sql, nil).Scan(tt.scanArgs...)
if err == nil {
t.Errorf("%d. Expected null to cause error, but it didn't (sql -> %v)", i, sql)
}
if err != nil && !strings.Contains(err.Error(), "Cannot decode null") {
t.Errorf(`%d. Expected null to cause error "Cannot decode null..." but it was %v (sql -> %v)`, i, err, sql)
}
}
}
}