mirror of https://github.com/jackc/pgx.git
parent
98543e0354
commit
c875abea84
|
@ -60,7 +60,9 @@ func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value any) Enc
|
|||
|
||||
elementEncodePlan := m.PlanEncode(c.ElementType.OID, format, elementType)
|
||||
if elementEncodePlan == nil {
|
||||
return nil
|
||||
if reflect.TypeOf(elementType) != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
switch format {
|
||||
|
|
|
@ -103,7 +103,7 @@ func TestArrayCodecArray(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestArrayCodecAnySlice(t *testing.T) {
|
||||
func TestArrayCodecNamedSliceType(t *testing.T) {
|
||||
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
type _int16Slice []int16
|
||||
|
||||
|
@ -126,6 +126,29 @@ func TestArrayCodecAnySlice(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
// https://github.com/jackc/pgx/issues/1488
|
||||
func TestArrayCodecAnySliceArgument(t *testing.T) {
|
||||
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
type _int16Slice []int16
|
||||
|
||||
for i, tt := range []struct {
|
||||
arg any
|
||||
expected []int16
|
||||
}{
|
||||
{[]any{1, 2, 3}, []int16{1, 2, 3}},
|
||||
} {
|
||||
var actual []int16
|
||||
err := conn.QueryRow(
|
||||
ctx,
|
||||
"select $1::smallint[]",
|
||||
tt.arg,
|
||||
).Scan(&actual)
|
||||
assert.NoErrorf(t, err, "%d", i)
|
||||
assert.Equalf(t, tt.expected, actual, "%d", i)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// https://github.com/jackc/pgx/issues/1442
|
||||
func TestArrayCodecAnyArray(t *testing.T) {
|
||||
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
|
|
Loading…
Reference in New Issue