mirror of
https://github.com/jackc/pgx.git
synced 2025-04-27 13:14:32 +00:00
When `LoadTypes` is being called, it does not include the namespace-qualified types in its result. While these namespaces are visible to `LoadTypes` itself, `RegisterTypes` will not recognise this form of the types, only allowing them to be used if they are on the schema path, and referred to without their namespace component.
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package pgx_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCompositeCodecTranscodeWithLoadTypes(t *testing.T) {
|
|
skipCockroachDB(t, "Server does not support composite types (see https://github.com/cockroachdb/cockroach/issues/27792)")
|
|
|
|
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
|
_, err := conn.Exec(ctx, `
|
|
drop type if exists dtype_test;
|
|
drop domain if exists anotheruint64;
|
|
|
|
create domain anotheruint64 as numeric(20,0);
|
|
create type dtype_test as (
|
|
a text,
|
|
b int4,
|
|
c anotheruint64,
|
|
d anotheruint64[]
|
|
);`)
|
|
require.NoError(t, err)
|
|
defer conn.Exec(ctx, "drop type dtype_test")
|
|
defer conn.Exec(ctx, "drop domain anotheruint64")
|
|
|
|
types, err := conn.LoadTypes(ctx, []string{"dtype_test"})
|
|
require.NoError(t, err)
|
|
require.Len(t, types, 6)
|
|
require.Equal(t, types[0].Name, "public.anotheruint64")
|
|
require.Equal(t, types[1].Name, "anotheruint64")
|
|
require.Equal(t, types[2].Name, "public._anotheruint64")
|
|
require.Equal(t, types[3].Name, "_anotheruint64")
|
|
require.Equal(t, types[4].Name, "public.dtype_test")
|
|
require.Equal(t, types[5].Name, "dtype_test")
|
|
})
|
|
}
|