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

Typegen is not respecting unique table constraint

Aperta
#612 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
postgresql, typescript
Ambito
databases

Direzione di ricerca

Riproduci lo schema con customers, addresses e orders, quindi esegui npx supabase gen types typescript --local > types/supabase.ts ed esamina i tipi di relazione generati. Segui il punto di ingresso della generazione dei tipi utilizzato da questo comando e verifica che la relazione univoca addresses.customer_id venga emessa come oggetto, mentre orders rimanga un array.

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

Descrizione

Describe the bug
I have three tables. One main table customers and two linked tables addresses and orders. They both are linked to the customers table's id column, but the addresses table has a unique constraint on customer_id relation column. The problem is that the generated types assumes that both table relations are one to many.

To Reproduce
Steps to reproduce the behavior:

  1. Start a new project and create three tables. Reference one main table from the two others, one with a unique constraint and one without.
  2. Generate types using npx supabase gen types typescript --local > types/supabase.ts
  3. Use const supabase = createClient<Database>() and query const { data } = supabase .from("customers") .select("*, orders (id), addresses (id)").single()
  4. see that the type of data.orders and data.addresses are both an array of objects.

Expected behavior
The types to respect the unique constraint and be an object and not an array of objects.

Desktop

  • OS: Mac OS 13.4.1
  • Version of CLI: v1.93.0
  • Version of supabase-js: v2.33.2
  • Version of Node.js: v16.14.2
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.