From 3956d437601b2c8d3868a3de9b63dade143c09f2 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Sat, 19 Oct 2024 15:47:23 +0800 Subject: [PATCH] fix(typegen): view relationships ordering --- src/server/templates/typescript.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/templates/typescript.ts b/src/server/templates/typescript.ts index 6f96c6e1..25c38a18 100644 --- a/src/server/templates/typescript.ts +++ b/src/server/templates/typescript.ts @@ -231,8 +231,10 @@ export type Database = { relationship.referenced_schema === view.schema && relationship.relation === view.name ) - .sort(({ foreign_key_name: a }, { foreign_key_name: b }) => - a.localeCompare(b) + .sort( + (a, b) => + a.foreign_key_name.localeCompare(b.foreign_key_name) || + a.referenced_relation.localeCompare(b.referenced_relation) ) .map( (relationship) => `{