2
0

Fix panic on assigning empty array to non-slice or array

See https://github.com/jackc/pgx/issues/881
This commit is contained in:
Jack Christensen
2020-11-27 11:56:21 -06:00
parent 740b3a5115
commit 00d516f5c4
25 changed files with 156 additions and 0 deletions
+12
View File
@@ -5,6 +5,7 @@ import (
"testing"
"github.com/jackc/pgtype"
"github.com/stretchr/testify/require"
)
func TestParseUntypedTextArray(t *testing.T) {
@@ -113,3 +114,14 @@ func TestParseUntypedTextArray(t *testing.T) {
}
}
}
// https://github.com/jackc/pgx/issues/881
func TestArrayAssignToEmptyToNonSlice(t *testing.T) {
var a pgtype.Int4Array
err := a.Set([]int32{})
require.NoError(t, err)
var iface interface{}
err = a.AssignTo(&iface)
require.EqualError(t, err, "cannot assign *pgtype.Int4Array to *interface {}")
}