Fix panic on assigning empty array to non-slice or array
See https://github.com/jackc/pgx/issues/881
This commit is contained in:
@@ -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 {}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user