2
0

Adds checks for zero length arrays.

Assigning values from nil or zero length elements or dimensions now return immediately as there are no values to assign.
This commit is contained in:
Simo Haasanen
2020-10-20 19:52:05 +01:00
parent e92478ec70
commit 9639a69d45
44 changed files with 210 additions and 0 deletions
+11
View File
@@ -214,6 +214,7 @@ func TestUUIDArrayAssignTo(t *testing.T) {
var byteArraySlice [][16]byte
var byteSliceSlice [][]byte
var stringSlice []string
var byteSlice []byte
var byteArraySliceDim2 [][][16]byte
var stringSliceDim4 [][][][]string
var byteArrayDim2 [2][1][16]byte
@@ -252,6 +253,16 @@ func TestUUIDArrayAssignTo(t *testing.T) {
dst: &byteSliceSlice,
expected: ([][]byte)(nil),
},
{
src: pgtype.UUIDArray{Status: pgtype.Present},
dst: &byteSlice,
expected: ([]byte)(nil),
},
{
src: pgtype.UUIDArray{Status: pgtype.Present},
dst: &stringSlice,
expected: (([]string)(nil)),
},
{
src: pgtype.UUIDArray{
Elements: []pgtype.UUID{{Bytes: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}},