mirror of
https://github.com/jackc/pgx.git
synced 2025-05-31 11:42:24 +00:00
handle null bytes
This commit is contained in:
parent
3c61b16776
commit
43e06f9c62
@ -191,6 +191,10 @@ func (r *msgReader) readBytes(count int32) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
if count < 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
b := make([]byte, int(count))
|
||||
|
||||
_, err := io.ReadFull(r.reader, b)
|
||||
|
@ -806,3 +806,18 @@ func TestReadingValueAfterEmptyArray(t *testing.T) {
|
||||
t.Errorf("Expected 'b' to 42, but it was: ", b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadingNullByteArray(t *testing.T) {
|
||||
conn := mustConnect(t, *defaultConnConfig)
|
||||
defer closeConn(t, conn)
|
||||
|
||||
var a []byte
|
||||
err := conn.QueryRow("select null::text").Scan(&a)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.QueryRow failed: ", err)
|
||||
}
|
||||
|
||||
if len(a) != 0 {
|
||||
t.Errorf("Expected 'a' to have length 0, but it was: ", len(a))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user