diff --git a/src/server/templates/typescript.ts b/src/server/templates/typescript.ts index 90c3cddd..d0048709 100644 --- a/src/server/templates/typescript.ts +++ b/src/server/templates/typescript.ts @@ -357,6 +357,8 @@ export interface Database { })()})${is_set_returning_function ? '[]' : ''} }` ) + // We only sorted by name on schemaFunctions - here we sort by arg names, arg types, and return type. + .sort() .join('|')}` ) })()} diff --git a/test/db/00-init.sql b/test/db/00-init.sql index f4fc17a9..ec1d9834 100644 --- a/test/db/00-init.sql +++ b/test/db/00-init.sql @@ -93,3 +93,6 @@ stable as $$ select id, name from public.users; $$; + +create or replace function public.polymorphic_function(text) returns void language sql as ''; +create or replace function public.polymorphic_function(bool) returns void language sql as ''; diff --git a/test/server/column-privileges.ts b/test/server/column-privileges.ts index 1a126067..b748c752 100644 --- a/test/server/column-privileges.ts +++ b/test/server/column-privileges.ts @@ -3,14 +3,15 @@ import { app } from './utils' test('list column privileges', async () => { const res = await app.inject({ method: 'GET', path: '/column-privileges' }) - expect( - res - .json() - .find( - ({ relation_schema, relation_name, column_name }) => - relation_schema === 'public' && relation_name === 'todos' && column_name === 'id' - ) - ).toMatchInlineSnapshot( + const column = res + .json() + .find( + ({ relation_schema, relation_name, column_name }) => + relation_schema === 'public' && relation_name === 'todos' && column_name === 'id' + )! + // We don't guarantee order of privileges, but we want to keep the snapshots consistent. + column.privileges.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))) + expect(column).toMatchInlineSnapshot( { column_id: expect.stringMatching(/^\d+\.\d+$/) }, ` { diff --git a/test/server/typegen.ts b/test/server/typegen.ts index a798a222..43a10f3d 100644 --- a/test/server/typegen.ts +++ b/test/server/typegen.ts @@ -240,6 +240,19 @@ test('typegen', async () => { name: string }[] } + polymorphic_function: + | { + Args: { + "": boolean + } + Returns: undefined + } + | { + Args: { + "": string + } + Returns: undefined + } postgres_fdw_disconnect: { Args: { "": string