Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

updates FDWs query to include tables and columns

Alaister Young471a65c9a734
diff --git a/studio/data/fdw/fdws-query.ts b/studio/data/fdw/fdws-query.ts
index f5b95f2904c..c2ba531dcd4 100644
--- a/studio/data/fdw/fdws-query.ts
+++ b/studio/data/fdw/fdws-query.ts
@@ -4,17 +4,49 @@ import { ExecuteSqlData, useExecuteSqlPrefetch, useExecuteSqlQuery } from '../sq
export const getFDWsSql = () => {
const sql = /* SQL */ `
select
- oid as id,
- srvname as name
- from pg_catalog.pg_foreign_server;
+ s.oid as "id",
+ s.srvname as "name",
+ (
+ select jsonb_agg(
+ jsonb_build_object(
+ 'id', c.oid,
+ 'name', c.relname,
+ 'columns', (
+ select jsonb_agg(
+ jsonb_build_object(
+ 'name', a.attname,
+ 'type', pg_catalog.format_type(a.atttypid, a.atttypmod)
+ )
+ )
+ from pg_catalog.pg_attribute a
+ where a.attrelid = c.oid and a.attnum > 0 and not a.attisdropped
+ )
+ )
+ )
+ from pg_catalog.pg_class c
+ where c.oid = any (select t.ftrelid from pg_catalog.pg_foreign_table t where t.ftserver = s.oid)
+ ) as "tables"
+ from pg_catalog.pg_foreign_server s;
`
return sql
}
+export type FDWColumn = {
+ name: string
+ type: string
+}
+
+export type FDWTable = {
+ id: string
+ name: string
+ columns: FDWColumn[]
+}
+
export type FDW = {
id: string
name: string
+ tables: FDWTable[]
}
export type FDWsResponse = {