mirror of https://github.com/jackc/pgx.git
Fix scanning null did not overwrite slice
parent
7427820aba
commit
0c6266ef30
|
@ -463,7 +463,7 @@ func (a FlatArray[T]) IndexType() any {
|
||||||
|
|
||||||
func (a *FlatArray[T]) SetDimensions(dimensions []ArrayDimension) error {
|
func (a *FlatArray[T]) SetDimensions(dimensions []ArrayDimension) error {
|
||||||
if dimensions == nil {
|
if dimensions == nil {
|
||||||
a = nil
|
*a = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1094,6 +1094,21 @@ func TestReadingNullByteArrays(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQueryNullSliceIsSet(t *testing.T) {
|
||||||
|
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||||
|
defer closeConn(t, conn)
|
||||||
|
|
||||||
|
a := []int32{1, 2, 3}
|
||||||
|
err := conn.QueryRow(context.Background(), "select null::int[]").Scan(&a)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("conn.QueryRow failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if a != nil {
|
||||||
|
t.Errorf("Expected 'a' to be nil, but it was: %v", a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestConnQueryDatabaseSQLScanner(t *testing.T) {
|
func TestConnQueryDatabaseSQLScanner(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue