add filter for dropped attributes in getCompositeType

pull/1498/head
Felix Röhrich 2023-02-07 00:51:30 +01:00 committed by Jack Christensen
parent 190c05cc24
commit fa5fbed497
2 changed files with 20 additions and 1 deletions

View File

@ -1282,7 +1282,7 @@ func (c *Conn) getCompositeFields(ctx context.Context, oid uint32) ([]pgtype.Com
var fieldOID uint32
rows, _ := c.Query(ctx, `select attname, atttypid
from pg_attribute
where attrelid=$1
where attrelid=$1 and not attisdropped
order by attnum`,
typrelid,
)

View File

@ -903,6 +903,25 @@ create type pgx_b.point as (c text);
})
}
func TestLoadCompositeType(t *testing.T) {
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server does support composite types (https://github.com/cockroachdb/cockroach/issues/27792)")
tx, err := conn.Begin(ctx)
require.NoError(t, err)
defer tx.Rollback(ctx)
_, err = tx.Exec(ctx, "create type compositetype as (attr1 int, attr2 int)")
require.NoError(t, err)
_, err = tx.Exec(ctx, "alter type compositetype drop attribute attr1")
require.NoError(t, err)
_, err = conn.LoadType(ctx, "compositetype")
require.NoError(t, err)
})
}
func TestLoadRangeType(t *testing.T) {
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server does support range types")