Skip to content

Commit 67f463c

Browse files
committed
fix(typegen): sort polymorphic function variants
1 parent 04af94b commit 67f463c

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/server/templates/typescript.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ export interface Database {
357357
})()})${is_set_returning_function ? '[]' : ''}
358358
}`
359359
)
360+
// We only sorted by name on schemaFunctions - here we sort by arg names, arg types, and return type.
361+
.sort()
360362
.join('|')}`
361363
)
362364
})()}

test/db/00-init.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ stable
9393
as $$
9494
select id, name from public.users;
9595
$$;
96+
97+
create or replace function public.polymorphic_function(text) returns void language sql as '';
98+
create or replace function public.polymorphic_function(bool) returns void language sql as '';

test/server/typegen.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,19 @@ test('typegen', async () => {
240240
name: string
241241
}[]
242242
}
243+
polymorphic_function:
244+
| {
245+
Args: {
246+
"": boolean
247+
}
248+
Returns: undefined
249+
}
250+
| {
251+
Args: {
252+
"": string
253+
}
254+
Returns: undefined
255+
}
243256
postgres_fdw_disconnect: {
244257
Args: {
245258
"": string

0 commit comments

Comments
 (0)