Open
Description
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:
- Start a new project and create three tables. Reference one main table from the two others, one with a unique constraint and one without.
- Generate types using
npx supabase gen types typescript --local > types/supabase.ts
- Use
const supabase = createClient<Database>()
and queryconst { data } = supabase .from("customers") .select("*, orders (id), addresses (id)").single()
- see that the type of
data.orders
anddata.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
Metadata
Metadata
Assignees
Labels
No labels