mirror of https://github.com/jackc/pgx.git
parent
98543e0354
commit
c875abea84
|
@ -60,8 +60,10 @@ func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value any) Enc
|
||||||
|
|
||||||
elementEncodePlan := m.PlanEncode(c.ElementType.OID, format, elementType)
|
elementEncodePlan := m.PlanEncode(c.ElementType.OID, format, elementType)
|
||||||
if elementEncodePlan == nil {
|
if elementEncodePlan == nil {
|
||||||
|
if reflect.TypeOf(elementType) != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch format {
|
switch format {
|
||||||
case BinaryFormatCode:
|
case BinaryFormatCode:
|
||||||
|
|
|
@ -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) {
|
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||||
type _int16Slice []int16
|
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
|
// https://github.com/jackc/pgx/issues/1442
|
||||||
func TestArrayCodecAnyArray(t *testing.T) {
|
func TestArrayCodecAnyArray(t *testing.T) {
|
||||||
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||||
|
|
Loading…
Reference in New Issue