pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Column comments on views and materialized views are not dumped or planned

Open tianzhou opened this issue 3 weeks ago • 0 comments

Problem

COMMENT ON COLUMN for columns of views and materialized views is not dumped and not planned. The column-comment lookup in the inspector only runs for tables, so view and matview column comments are silently lost on dump/apply and never diffed.

Reproduction

CREATE TABLE t (id int PRIMARY KEY, name text);
CREATE VIEW v AS SELECT id, name FROM t;
CREATE MATERIALIZED VIEW mv AS SELECT id, name FROM t;
COMMENT ON COLUMN t.name IS 'table column';
COMMENT ON COLUMN v.name IS 'view column';
COMMENT ON COLUMN mv.name IS 'matview column';

pgschema dump --schema public contains COMMENT ON COLUMN t.name IS 'table column' only. After applying the dump to an empty database, pg_description has no entries for v or mv columns, and plan against the original database reports no difference.

Expected behavior

Column comments on views and materialized views should be dumped as COMMENT ON COLUMN v.name IS ..., compared, and re-emitted when a view is recreated, the same as table column comments.

Verification and scope

Reproduced on PostgreSQL 18.1 with pgschema 1.14.1 (91623d0b). In the #597 schema, 37 column comments on public.taxon_mv and 4 on the view public.wfo_export are lost. Table, view and matview comments at the relation level are handled correctly.

tianzhou avatar Nov 08 '26 08:11 tianzhou