From 05a4760dc0680b6bd044a40411ce89efe0fd11b9 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Thu, 10 Oct 2024 03:35:21 +0800 Subject: [PATCH] fix(typegen): don't generate relationships across schemas PostgREST doesn't detect relationships across schemas --- src/server/templates/typescript.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server/templates/typescript.ts b/src/server/templates/typescript.ts index f5aa1c58..6f96c6e1 100644 --- a/src/server/templates/typescript.ts +++ b/src/server/templates/typescript.ts @@ -151,6 +151,7 @@ export type Database = { .filter( (relationship) => relationship.schema === table.schema && + relationship.referenced_schema === table.schema && relationship.relation === table.name ) .sort( @@ -226,7 +227,9 @@ export type Database = { ${relationships .filter( (relationship) => - relationship.schema === view.schema && relationship.relation === view.name + relationship.schema === view.schema && + relationship.referenced_schema === view.schema && + relationship.relation === view.name ) .sort(({ foreign_key_name: a }, { foreign_key_name: b }) => a.localeCompare(b)