Skip to content

Typescript generated types not working for relationships #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
dreinon opened this issue Mar 11, 2025 · 5 comments
Open
2 tasks done

Typescript generated types not working for relationships #609

dreinon opened this issue Mar 11, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@dreinon
Copy link

dreinon commented Mar 11, 2025

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I have set up generated typescript types in my project and they work well until I try to get related data.

I have a call like this:
supabase.from('group').select('displayName, event (id)')

And it outputs the following return type:
{ error: true; } & "could not find the relation between group and event"

If you ignore typescript errors, the query works without errors and gets the correct embeded data.

I attach the chunk of the generated db types from both event and group tables.
This is a one-to-many relationship, one group can have many events assigned (through promoter column in event table). Promoter is not primary key but since it is not a many-to-many relationship I think it is not necessary, right? I would appreciate some help. Thanks!

Image

@dreinon dreinon added the bug Something isn't working label Mar 11, 2025
@dreinon
Copy link
Author

dreinon commented Mar 25, 2025

Hi, any idea on this? Thanks!

@soedirgo
Copy link
Member

Can you try upgrading the CLI and the SDK? The generated types look outdated to me

@dreinon
Copy link
Author

dreinon commented Apr 10, 2025

Hi @soedirgo, I updated everything but the exact same type error is still there. I remind that the call to supabase actually returns the correct data, it's only the types that fail.

Versions:

cli: "supabase": "^2.20.12",
ssr: "@supabase/ssr": "^0.6.1"
supabase-js: "@supabase/supabase-js": "^2.49.4"

My types look like this now:
Image

Also, promoter column appears configured like this in the dashboard:

Image

@dreinon
Copy link
Author

dreinon commented May 5, 2025

Hi, sorry to reask, but any idea on this? Thanks!

@soedirgo
Copy link
Member

soedirgo commented May 6, 2025

Can you set up an example repo where we can replicate this? It's difficult to reproduce the problem otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants