Skip to content

Fix: include views in PostgreSQL getTableComment() relkind filter#297

Merged
tianzhou merged 2 commits intomainfrom
fix/issue-296-view-comments
Apr 2, 2026
Merged

Fix: include views in PostgreSQL getTableComment() relkind filter#297
tianzhou merged 2 commits intomainfrom
fix/issue-296-view-comments

Conversation

@tianzhou
Copy link
Copy Markdown
Member

@tianzhou tianzhou commented Apr 2, 2026

Summary

  • getTableComment() in the PostgreSQL connector filtered pg_class.relkind IN ('r','p','m','f'), excluding 'v' (ordinary views)
  • Views returned by search_objects always had null comments despite COMMENT ON VIEW being set
  • Added 'v' to the relkind filter so obj_description() can return view comments

Closes #296

Test plan

  • Existing unit tests pass
  • Verify with PostgreSQL: create a view with COMMENT ON VIEW, call search_objects with detail_level: "full", confirm comment is returned

🤖 Generated with Claude Code

The relkind filter excluded 'v' (ordinary views), so view comments
were always null even when set via COMMENT ON VIEW.

Closes #296

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 2, 2026 15:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes PostgreSQL view comments not appearing in search_objects output by aligning getTableComment()’s pg_class.relkind filter with objects returned from discovery, so obj_description() can resolve comments for ordinary views.

Changes:

  • Include relkind = 'v' (ordinary views) in getTableComment()’s pg_class.relkind filter to return COMMENT ON VIEW values.

Comment on lines 382 to 386
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = $1
AND n.nspname = $2
AND c.relkind IN ('r','p','m','f')
AND c.relkind IN ('r','p','m','f','v')
`,
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This change expands getTableComment() to include ordinary views (relkind='v'), but there’s no test asserting that a COMMENT ON VIEW is surfaced (either via getTableComment('view_name') or through search_objects detail output). Since integration tests already cover table comments, please add a corresponding view comment case to prevent regressions.

Copilot uses AI. Check for mistakes.
Creates a view with COMMENT ON VIEW in the test setup and asserts
that getTableComment() returns the comment for views.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@tianzhou tianzhou merged commit f319114 into main Apr 2, 2026
6 checks passed
amansingh63 added a commit to amansingh63/dbhub-analytics that referenced this pull request Apr 2, 2026
Upstream changes:
- Make @aws-sdk/rds-signer and @azure/identity optional (bytebase#298)
- Fix PostgreSQL view comments in getTableComment() (bytebase#297)
- Version bump 0.21.0 → 0.21.1

Conflicts resolved: README.md, package.json, server.json, tsup.config.ts
(kept dbhub-analytics branding, merged upstream code changes)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Bug: search_objects does not return comments for views

2 participants