mirror of
https://github.com/jackc/pgx.git
synced 2025-04-27 21:25:53 +00:00
add filter for dropped attributes in getCompositeType
This commit is contained in:
parent
190c05cc24
commit
fa5fbed497
2
conn.go
2
conn.go
@ -1282,7 +1282,7 @@ func (c *Conn) getCompositeFields(ctx context.Context, oid uint32) ([]pgtype.Com
|
|||||||
var fieldOID uint32
|
var fieldOID uint32
|
||||||
rows, _ := c.Query(ctx, `select attname, atttypid
|
rows, _ := c.Query(ctx, `select attname, atttypid
|
||||||
from pg_attribute
|
from pg_attribute
|
||||||
where attrelid=$1
|
where attrelid=$1 and not attisdropped
|
||||||
order by attnum`,
|
order by attnum`,
|
||||||
typrelid,
|
typrelid,
|
||||||
)
|
)
|
||||||
|
19
conn_test.go
19
conn_test.go
@ -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) {
|
func TestLoadRangeType(t *testing.T) {
|
||||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
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")
|
pgxtest.SkipCockroachDB(t, conn, "Server does support range types")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user