mirror of https://github.com/jackc/pgx.git
parent
ac9d4f4d96
commit
335c8621ff
|
@ -1921,13 +1921,15 @@ func (w *sqlScannerWrapper) Scan(src any) error {
|
|||
}
|
||||
|
||||
var bufSrc []byte
|
||||
switch src := src.(type) {
|
||||
case string:
|
||||
bufSrc = []byte(src)
|
||||
case []byte:
|
||||
bufSrc = src
|
||||
default:
|
||||
bufSrc = []byte(fmt.Sprint(bufSrc))
|
||||
if src != nil {
|
||||
switch src := src.(type) {
|
||||
case string:
|
||||
bufSrc = []byte(src)
|
||||
case []byte:
|
||||
bufSrc = src
|
||||
default:
|
||||
bufSrc = []byte(fmt.Sprint(bufSrc))
|
||||
}
|
||||
}
|
||||
|
||||
return w.m.Scan(t.OID, TextFormatCode, bufSrc, w.v)
|
||||
|
|
|
@ -394,6 +394,10 @@ func TestConnQueryScanArray(t *testing.T) {
|
|||
err := db.QueryRow("select '{1,2,3}'::bigint[]").Scan(m.SQLScanner(&a))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, pgtype.Array[int64]{Elements: []int64{1, 2, 3}, Dims: []pgtype.ArrayDimension{{Length: 3, LowerBound: 1}}, Valid: true}, a)
|
||||
|
||||
err = db.QueryRow("select null::bigint[]").Scan(m.SQLScanner(&a))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, pgtype.Array[int64]{Elements: nil, Dims: nil, Valid: false}, a)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue