Repository navigation
fix: dump and plan column comments on views and materialized views (#698) - #722
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
[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
SummaryAdds column-comment support for views and materialized views.
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: |
There was a problem hiding this comment.
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>
Summary
Fixes #698.
COMMENT ON COLUMNon a view or materialized view was neither inspected nor diffed, so dump dropped it and plan never detected adds/changes/removals.GetViewsForSchemanow also aggregatescol_description(view_oid, attnum)inattnumorder (alongsidecolumn_names/column_types); the inspector turns it intoir.View.ColumnComments map[string]string(commented columns only, included in JSON/fingerprint).view.column.commentandmaterialized_view.column.comment, emitted bygenerateViewColumnCommentsSQL(old, new, ...)in column order:CREATE OR REPLACE VIEW, which keeps column comments): only changed ones,IS NULLfor removalsCREATE OR REPLACE VIEW).ir/queries/queries.sql.gowas updated by hand to mirrorqueries.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 alongsideCREATE 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