Skip to content

Commit a7a3f26

Browse files
committed
fix(typegen): use javascript deterministic sort for args join
1 parent 95a7907 commit a7a3f26

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/server/templates/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export type Database = {
304304
})
305305
return `{ ${argsNameAndType.map(({ name, type, has_default }) => `${JSON.stringify(name)}${has_default ? '?' : ''}: ${type}`)} }`
306306
})
307+
.toSorted()
307308
// A function can have multiples definitions with differents args, but will always return the same type
308309
.join(' | ')}
309310
Returns: ${(() => {

test/server/typegen.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ test('typegen: typescript', async () => {
511511
}
512512
get_todos_setof_rows: {
513513
Args:
514-
| { user_row: Database["public"]["Tables"]["users"]["Row"] }
515514
| { todo_row: Database["public"]["Tables"]["todos"]["Row"] }
515+
| { user_row: Database["public"]["Tables"]["users"]["Row"] }
516516
Returns: {
517517
details: string | null
518518
id: number
@@ -547,7 +547,7 @@ test('typegen: typescript', async () => {
547547
Returns: Record<string, unknown>[]
548548
}
549549
polymorphic_function: {
550-
Args: { "": string } | { "": boolean }
550+
Args: { "": boolean } | { "": string }
551551
Returns: undefined
552552
}
553553
postgres_fdw_disconnect: {
@@ -1243,8 +1243,8 @@ test('typegen w/ one-to-one relationships', async () => {
12431243
}
12441244
get_todos_setof_rows: {
12451245
Args:
1246-
| { user_row: Database["public"]["Tables"]["users"]["Row"] }
12471246
| { todo_row: Database["public"]["Tables"]["todos"]["Row"] }
1247+
| { user_row: Database["public"]["Tables"]["users"]["Row"] }
12481248
Returns: {
12491249
details: string | null
12501250
id: number
@@ -1279,7 +1279,7 @@ test('typegen w/ one-to-one relationships', async () => {
12791279
Returns: Record<string, unknown>[]
12801280
}
12811281
polymorphic_function: {
1282-
Args: { "": string } | { "": boolean }
1282+
Args: { "": boolean } | { "": string }
12831283
Returns: undefined
12841284
}
12851285
postgres_fdw_disconnect: {
@@ -1975,8 +1975,8 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
19751975
}
19761976
get_todos_setof_rows: {
19771977
Args:
1978-
| { user_row: Database["public"]["Tables"]["users"]["Row"] }
19791978
| { todo_row: Database["public"]["Tables"]["todos"]["Row"] }
1979+
| { user_row: Database["public"]["Tables"]["users"]["Row"] }
19801980
Returns: {
19811981
details: string | null
19821982
id: number
@@ -2011,7 +2011,7 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
20112011
Returns: Record<string, unknown>[]
20122012
}
20132013
polymorphic_function: {
2014-
Args: { "": string } | { "": boolean }
2014+
Args: { "": boolean } | { "": string }
20152015
Returns: undefined
20162016
}
20172017
postgres_fdw_disconnect: {

0 commit comments

Comments
 (0)