Allow scanning null even if PG and Go types are incompatible
refs https://github.com/jackc/pgx/issues/1326
This commit is contained in:
@@ -329,6 +329,21 @@ func TestMapScanPointerToRenamedType(t *testing.T) {
|
||||
assert.Equal(t, "foo", string(*rs))
|
||||
}
|
||||
|
||||
// https://github.com/jackc/pgx/issues/1326
|
||||
func TestMapScanNullToWrongType(t *testing.T) {
|
||||
m := pgtype.NewMap()
|
||||
|
||||
var n *int32
|
||||
err := m.Scan(pgtype.TextOID, pgx.TextFormatCode, nil, &n)
|
||||
assert.NoError(t, err)
|
||||
assert.Nil(t, n)
|
||||
|
||||
var pn pgtype.Int4
|
||||
err = m.Scan(pgtype.TextOID, pgx.TextFormatCode, nil, &pn)
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, pn.Valid)
|
||||
}
|
||||
|
||||
func BenchmarkMapScanInt4IntoBinaryDecoder(b *testing.B) {
|
||||
m := pgtype.NewMap()
|
||||
src := []byte{0, 0, 0, 42}
|
||||
|
||||
Reference in New Issue
Block a user