Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#1,111 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, typescript
Ambito
database

Direzione di ricerca

Inizia da FUNCTIONS_SQL e dal punto di ingresso functions.retrieve(), quindi esamina i fixtures in test/db/00-init.sql. Riproduci la ricerca della funzione sovraccaricata e aggiungi la coverage sia per un overload esistente senza argomenti sia per uno mancante. Il lavoro è completato quando args: [] seleziona solo la funzione senza argomenti e, negli altri casi, restituisce l’errore cannot-find-function esistente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

PostgresMeta.functions.retrieve({ schema, name, args: [] }) is supposed to select the zero-argument overload of a function. When the name is overloaded, the empty args array currently skips the proargtypes filter, so the query returns an arbitrary overload (data[0]).

functions.create() calls retrieve() after creating the function, so creating a zero-argument overload of an existing name can also return the wrong function.

To Reproduce

Using the fixtures in test/db/00-init.sql:

create or replace function public.polymorphic_function_with_no_params_or_unnamed() returns int language sql as 'SELECT 1';
create or replace function public.polymorphic_function_with_no_params_or_unnamed(bool) returns int language sql as 'SELECT 2';
create or replace function public.polymorphic_function_with_no_params_or_unnamed(text) returns text language sql as $$ SELECT 'foo' $$;
await pgMeta.functions.retrieve({
  schema: 'public',
  name: 'polymorphic_function_with_no_params_or_unnamed',
  args: [],
})

Expected behavior

The zero-argument overload is returned (argument_types === '', return_type === 'integer').

If no zero-argument overload exists, retrieve should return the existing "cannot find function" error.

Actual behavior

A different overload is returned. On the test fixtures this is the text overload (argument_types === 'text').

Root cause

In FUNCTIONS_SQL, an empty args array takes the args.length > 0 false branch and emits no p.proargtypes predicate. The inner "''" comparison for the empty-oidvector case is therefore dead code. retrieve() always passes args (default []), so name-based lookup never filters zero-argument functions.

Additional context

Existing tests only cover args: [] for a uniquely named zero-argument function (function_returning_set_of_rows), which hides the bug.

  • Library: @supabase/postgres-meta
  • Branch analyzed: master (641831e)
Lingua principale
TypeScript
Stelle
1.2k
Fork
224
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di supabase/postgres-meta

Tutte le issue di supabase/postgres-meta

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.