Skip to content

Commit

Permalink
fix(typegen): don't generate relationships across schemas
Browse files Browse the repository at this point in the history
PostgREST doesn't detect relationships across schemas
  • Loading branch information
soedirgo committed Oct 9, 2024
1 parent e0ad110 commit 2e54f31
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/server/templates/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export type Database = {
.filter(
(relationship) =>
relationship.schema === table.schema &&
relationship.referenced_schema === table.schema &&
relationship.relation === table.name
)
.sort(
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2e54f31

Please sign in to comment.