Skip to content
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

Incorrect types on SELECT when spreading related tables #482

Open
2 tasks done
masda70 opened this issue Oct 2, 2023 · 3 comments
Open
2 tasks done

Incorrect types on SELECT when spreading related tables #482

masda70 opened this issue Oct 2, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@masda70
Copy link

masda70 commented Oct 2, 2023

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

Spreading related tables, as described in this article , are not properly typed.

const { data } = await supabase.from('films').select(`
    title,
    ...technical_specs (
      camera, laboratory, duration
    )
  `)
console.log(data)

yields ParserError<"Expected identifier at ...technical_specs (camera, laboratory, duration)

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Use the table definitions from https://supabase.com/blog/postgrest-11-prerelease
  2. Write the above code within a supabase client environment.
  3. Build the project

Expected behavior

The type should be {title: string, camera: string, laboratory: string, duration: string}[] | null

System information

  • OS: [e.g. Ubuntu]
  • Version of supabase-js: 2.37.0
  • Version of Node.js: v18.17.1
@masda70 masda70 added the bug Something isn't working label Oct 2, 2023
@nielsvanrijn
Copy link

No update on this?
@masda70 did you find a workaround or did you just use .returns<...>() ?

@masda70
Copy link
Author

masda70 commented Apr 30, 2024

@nielsvanrijn I ended up not using the spread operator. I did retry using it 2 months ago, but noticed no difference in behavior.

@bnjmnt4n
Copy link
Contributor

bnjmnt4n commented May 1, 2024

This should be fixed in #497, which was released just about 2 months ago. If you upgrade to the latest version, this should be working fine.

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

3 participants