Skip to content

fix: retrieve the zero-argument function overload when args is empty - #1112

Open
hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/retrieve-zero-arg-function-overload
Open

fix: retrieve the zero-argument function overload when args is empty#1112
hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/retrieve-zero-arg-function-overload

Conversation

@hsusul

@hsusul hsusul commented Aug 23, 2026

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix.

Why?

functions.retrieve({ schema, name, args: [] }) is documented by the existing tests as selecting the zero-argument overload. FUNCTIONS_SQL skipped the proargtypes predicate whenever args was empty, so overloaded names returned data[0] instead of the no-arg signature.

functions.create() looks the function up the same way after CREATE FUNCTION, so creating a zero-argument overload of an existing name could also return the wrong row.

Fixes #1111.

How?

When args is provided, always filter on p.proargtypes::text. Non-empty argument lists still resolve type OIDs the same way; args: [] now compares against the empty oidvector (''), which was already present as dead code.

Checklist

  • Bug fix
  • Tests added
  • Docs
  • Breaking change

New tests

retrieve function by args filter - zero-argument overload among polymorphic functions uses the existing polymorphic_function_with_no_params_or_unnamed fixtures. Before the fix it received the text overload; after the fix it receives the zero-argument integer overload.

functions.retrieve skipped the proargtypes filter for args: [], so overloaded names could return the wrong signature.
@hsusul
hsusul requested review from a team, avallete and soedirgo as code owners August 23, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

functions.retrieve with args: [] returns the wrong overload for zero-argument functions

1 participant