Skip to content

[supabase-js] Parser error for using aggregate and spread #524

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

Closed
2 tasks done
thecoorum opened this issue Mar 11, 2024 · 6 comments
Closed
2 tasks done

[supabase-js] Parser error for using aggregate and spread #524

thecoorum opened this issue Mar 11, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@thecoorum
Copy link

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

A clear and concise description of what the bug is.

To Reproduce

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

  1. Create a typed Supabase client with (types are generated with npx supabase gen types typescript --local
    createClient<Database>(...)
    
  2. Try to query data
    2a. Using spread in select
    .select('...users (first_name, last_name)')
    2b. Using newly introduced aggregate functions
    .select('from:from_time.min(), till:till_time.max()')

2a will type fail with PostgrestSingleResponse<ParserError<"Expected identifier at '...users (first_name, last_name'">>
2b will type fail with PostgrestSingleResponse<ParserError<"Unexpected input: .min(), till:till_time.max()">>

Expected behavior

No TypeScript errors

System information

  • OS: macOS
  • Version of supabase-js: ^2.39.7
  • Version of Node.js: 19.4.0
@thecoorum thecoorum added the bug Something isn't working label Mar 11, 2024
@encima encima transferred this issue from supabase/supabase Mar 12, 2024
@encima
Copy link
Member

encima commented Mar 12, 2024

Also transferring issue to postgrest-js repo. Related to #447 which was fixed recently. Could be combined with #523 and #520

@stefan-girlich
Copy link

@encima Would you know if there is a workaround? Right now, I'm casting all outputs to any before further processing. Maybe there is an casting-based approach utilizing the Supabase types that are already generated.

@bnjmnt4n
Copy link
Contributor

bnjmnt4n commented Apr 9, 2024

@stefan-girlich are you using the latest version of supabase-js?

@stefan-girlich
Copy link

Thanks for the hint. I upgraded supabase-js, but I'm now seeing a new error. I added an updated in my original bug report.

@avallete
Copy link
Member

Hey everyone !

We've reworked the result inference in postgrest-js to address the typing issues mentioned above. The changes are available in a canary release, and we're actively seeking your feedback.

To test it out, update your supabase-js to version 2.46.0-rc.1 (which includes postgrest-js 1.17.0-rc.1):

npm install [email protected]

Please let us know if you encounter any issues, especially with retro-compatibility, so we can finalize it for the next release.

@avallete
Copy link
Member

The fix has been released in supabase-js v2.46.0. I'm closing this issue, but feel free to reopen if you encounter any further errors.

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

5 participants