fix(postgres): include foreign tables in search_objects - #419
Merged
Conversation
…can discover them Postgres reports foreign tables (postgres_fdw, file_fdw, ...) in information_schema.tables with table_type = 'FOREIGN', so the 'BASE TABLE' filter hid them from search_objects even though every per-table detail query (columns, comment, row count, tableExists) already handled them. Widen the filter to include 'FOREIGN'. Also let getTableIndexes see partitioned tables (relkind 'p'), which carry their own index entries since PG11 but were filtered out. Adds integration coverage using a handler-less FDW so the foreign table can be enumerated and described without a remote server. Closes #418 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Yc1YYa3jHCEW7FDxC66R9Z
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes are small, scoped to Postgres metadata enumeration, and are supported by targeted integration tests covering the new foreign-table behavior.
Pull request overview
This PR fixes a Postgres connector discovery gap so search_objects can enumerate foreign tables (FDW-backed) and their columns by ensuring getTables() includes information_schema.tables.table_type = 'FOREIGN', and it also improves index enumeration for partitioned tables.
Changes:
- Update Postgres
getTables()to includetable_type IN ('BASE TABLE', 'FOREIGN')so foreign tables become discoverable. - Update Postgres
getTableIndexes()to include partitioned tables (relkind IN ('r','p')) when enumerating indexes. - Add Postgres integration coverage for foreign-table discovery/description behavior; adjust shared integration-test comment wording.
File summaries
| File | Description |
|---|---|
| src/connectors/postgres/index.ts | Expands table discovery to include foreign tables and broadens index enumeration to cover partitioned tables. |
| src/connectors/tests/postgres.integration.test.ts | Adds integration tests and fixtures to validate foreign table discovery and description behavior. |
| src/connectors/tests/shared/integration-test-base.ts | Comment wording update to reflect getTables() semantics (tables only, never views). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #418
Problem
Postgres reports foreign tables (
postgres_fdw,file_fdw, ...) ininformation_schema.tableswithtable_type = 'FOREIGN'. The Postgres connector'sgetTablesfiltered ontable_type = 'BASE TABLE'only, sosearch_objectsnever listed foreign tables, and the column search (which builds its list fromgetTables+getViews) never listed their columns either.This was an enumeration-only gap: every per-table detail query already handled foreign tables.
getTableSchemareadsinformation_schema.columns(which includes them),getTableRowCountandgetTableCommentalready acceptrelkind = 'f', andtableExistshas no type filter. An agent that already knew the name could describe and query the table but could not discover it.Changes
src/connectors/postgres/index.tsgetTables: filter ontable_type IN ('BASE TABLE', 'FOREIGN').getTableIndexes: acceptrelkind IN ('r','p')instead of'r'only, so partitioned tables (which carry their own index entries since PG11) report their indexes. Foreign tables cannot have indexes and correctly return an empty list.src/connectors/__tests__/postgres.integration.test.ts: fixture creates a foreign table on a handler-less foreign data wrapper (no extension or remote server needed; catalog entries exist and can be enumerated/described, the table just can't be scanned). New tests assert the foreign table appears ingetTables, not ingetViews, passestableExists, and thatgetTableSchema,getTableComment, andgetTableIndexesbehave like they do for regular tables.src/connectors/__tests__/shared/integration-test-base.ts: comment wording only.No change to other connectors (no equivalent concept in MySQL/MariaDB/SQL Server/SQLite) or to the
Connectorinterface contract (getTablesstill excludes views).Not included
Materialized views are also missing from both
getTablesandgetViewsbecauseinformation_schema.tablesomits them entirely. Fixing that properly also requires changinggetTableSchema, sinceinformation_schema.columnsdoes not describe materialized views. Left for a follow-up to keep this change scoped to the issue.Testing
pnpm run test:unit: 997 tests pass.tsc --noEmit: clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Yc1YYa3jHCEW7FDxC66R9Z
Generated by Claude Code