Skip to content

fix: dump and plan column comments on views and materialized views (#698) - #722

Merged
tianzhou merged 2 commits into
mainfrom
devin/1795881409-view-column-comments
Nov 29, 2026
Merged

tianzhou merged 2 commits into
mainfrom
devin/1795881409-view-column-comments

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #698. COMMENT ON COLUMN on a view or materialized view was neither inspected nor diffed, so dump dropped it and plan never detected adds/changes/removals.

  • GetViewsForSchema now also aggregates col_description(view_oid, attnum) in attnum order (alongside column_names / column_types); the inspector turns it into ir.View.ColumnComments map[string]string (commented columns only, included in JSON/fingerprint).
  • New diff types view.column.comment and materialized_view.column.comment, emitted by generateViewColumnCommentsSQL(old, new, ...) in column order:
    • create / DROP+CREATE recreate / dependent-view recreate: all comments of the new view (dropping the relation drops its column comments)
    • in-place modify (comment-only or CREATE OR REPLACE VIEW, which keeps column comments): only changed ones, IS NULL for removals
  • A column-comment-only change takes the metadata path (no CREATE OR REPLACE VIEW).

ir/queries/queries.sql.go was updated by hand to mirror queries.sql (sqlc generate needs a live DB).

Tests (folded into existing cases): comment/add_view_comment (add/change/remove on view + matview, new matview with column comment), comment/noop_column_comments (no diff when unchanged), create_view/alter_view (change alongside CREATE OR REPLACE), create_materialized_view/alter_materialized_view (comment re-emitted after recreate). The comment cases failed before the fix.

Link to Devin session: https://app.devin.ai/sessions/314326a464fb4b3c9fbe6ccc32736cdf
Open in Devin Desktop: https://app.devin.ai/desktop/session/314326a464fb4b3c9fbe6ccc32736cdf?variant=devin
Requested by: @tianzhou


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking gap in multi-file dump test coverage.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect view inspection, migration plans, and schema dumps.

The PR appears safe to merge, with a non-blocking gap in multi-file dump test coverage.

Findings

  1. P2 Dump grouping lacks test coverage ▶

Summary

Adds column-comment support for views and materialized views.

  • View comments now stay attached to their columns in plans and dumps.

Reviews (1) · Last reviewed commit: "fix: dump and plan column comments on vi..." · Reviewed by Greptile

return parts[1] // Return view name
}
case diff.DiffTypeViewComment:
case diff.DiffTypeViewComment, diff.DiffTypeViewColumnComment, diff.DiffTypeMaterializedViewColumnComment:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Dump grouping lacks test coverage

The new grouping of view and materialized-view column comments has no regression test. The added fixtures check migration plans, but none checks that a multi-file dump keeps these comments in their parent files. Add a formatter test that checks both output files and their include order. Otherwise, a later change could put comments in separate files without the tests noticing.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

…he schema

Co-Authored-By: Tianzhou <t@bytebase.com>

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@tianzhou
tianzhou merged commit 65b7db2 into main Nov 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant