Skip to content

Commit f319114

Browse files
tianzhouclaude
andauthored
Fix: include views in PostgreSQL getTableComment() relkind filter (#297)
* Fix: include views in PostgreSQL getTableComment() relkind filter 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> * Add integration test for view comment in PostgreSQL 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> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4236ba4 commit f319114

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/connectors/__tests__/postgres.integration.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ class PostgreSQLIntegrationTest extends IntegrationTestBase<PostgreSQLTestContai
167167
ON CONFLICT DO NOTHING
168168
`, {});
169169

170+
// Create a view with a comment (for view comment test)
171+
await connector.executeSQL(`
172+
CREATE OR REPLACE VIEW active_users AS SELECT id, name, email FROM users WHERE age >= 25
173+
`, {});
174+
await connector.executeSQL(`COMMENT ON VIEW active_users IS 'Users aged 25 or older'`, {});
175+
170176
// Create test stored procedures using SQL language to avoid dollar quoting
171177
await connector.executeSQL(`
172178
CREATE OR REPLACE FUNCTION get_user_count()
@@ -245,6 +251,11 @@ describe('PostgreSQL Connector Integration Tests', () => {
245251
expect(result.rows[0].array_val).toBeDefined();
246252
});
247253

254+
it('should return comment for views via getTableComment', async () => {
255+
const comment = await postgresTest.connector.getTableComment!('active_users');
256+
expect(comment).toBe('Users aged 25 or older');
257+
});
258+
248259
it('should handle PostgreSQL returning clause', async () => {
249260
const result = await postgresTest.connector.executeSQL(
250261
"INSERT INTO users (name, email, age) VALUES ('Returning Test', 'returning@example.com', 40) RETURNING id, name",

src/connectors/postgres/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export class PostgresConnector implements Connector {
382382
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
383383
WHERE c.relname = $1
384384
AND n.nspname = $2
385-
AND c.relkind IN ('r','p','m','f')
385+
AND c.relkind IN ('r','p','m','f','v')
386386
`,
387387
[tableName, schemaToUse]
388388
);

0 commit comments

Comments
 (0)