Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/lib/sql/functions.sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ with functions as (
${
props.args === undefined
? ''
: props.args.length > 0
? `p.proargtypes::text = ${
props.args.length
? `(
: `p.proargtypes::text = ${
props.args.length > 0
? `(
SELECT STRING_AGG(type_oid::text, ' ') FROM (
SELECT (
split_args.arr[
Expand All @@ -60,9 +59,8 @@ with functions as (
) AS split_args
) args
)`
: "''"
} AND`
: ''
: "''"
} AND`
}
p.prokind = 'f'
)
Expand Down
16 changes: 16 additions & 0 deletions test/lib/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,19 @@ test('retrieve function by args filter - function with no arguments', async () =
})
expect(res.error).toBeNull()
})

test('retrieve function by args filter - zero-argument overload among polymorphic functions', async () => {
const res = await pgMeta.functions.retrieve({
schema: 'public',
name: 'polymorphic_function_with_no_params_or_unnamed',
args: [],
})
expect(res.error).toBeNull()
expect(res.data).toMatchObject({
name: 'polymorphic_function_with_no_params_or_unnamed',
schema: 'public',
argument_types: '',
args: [],
return_type: 'integer',
})
})