Describe the bug
PostgresMeta.foreignTables.retrieve({ id }) (and GET /foreign-tables/:id) does not filter foreign tables by OID. idsFilter is computed and passed into the columns CTE, but not into FOREIGN_TABLES_SQL, so the query returns every foreign table and the handler takes data[0].
With two or more foreign tables, retrieve-by-id can return a different table than the requested ID. Columns for the requested OID may attach to the wrong row (often an empty columns array).
To Reproduce
// two foreign tables: foreign_table and foreign_table_2
const listed = await pgMeta.foreignTables.list({ includeColumns: false })
const second = listed.data.find((ft) => ft.name === 'foreign_table_2')
const retrieved = await pgMeta.foreignTables.retrieve({ id: second.id })
// retrieved.data.name === 'foreign_table' (wrong)
Expected behavior
The foreign table whose id matches is returned, including its columns. Missing IDs still yield “Cannot find a foreign table with ID …”.
Views/tables/materialized views already pass idsFilter into their relation CTE.
Actual behavior
The first foreign table row is returned regardless of the requested id.
Additional context
FOREIGN_TABLES_SQL already supports idsFilter; generateEnrichedForeignTablesSql just never forwards it. Existing tests only retrieve by name, and the fixture has a single foreign table.
- Library:
@supabase/postgres-meta
- Branch analyzed:
master (641831e)
Describe the bug
PostgresMeta.foreignTables.retrieve({ id })(andGET /foreign-tables/:id) does not filter foreign tables by OID.idsFilteris computed and passed into the columns CTE, but not intoFOREIGN_TABLES_SQL, so the query returns every foreign table and the handler takesdata[0].With two or more foreign tables, retrieve-by-id can return a different table than the requested ID. Columns for the requested OID may attach to the wrong row (often an empty
columnsarray).To Reproduce
Expected behavior
The foreign table whose
idmatches is returned, including its columns. Missing IDs still yield “Cannot find a foreign table with ID …”.Views/tables/materialized views already pass
idsFilterinto their relation CTE.Actual behavior
The first foreign table row is returned regardless of the requested id.
Additional context
FOREIGN_TABLES_SQLalready supportsidsFilter;generateEnrichedForeignTablesSqljust never forwards it. Existing tests only retrieve by name, and the fixture has a single foreign table.@supabase/postgres-metamaster(641831e)