postgrest-js icon indicating copy to clipboard operation
postgrest-js copied to clipboard

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

Open thecoorum opened this issue 11 months ago • 5 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] 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 avatar Mar 11 '24 14:03 thecoorum

Also transferring issue to postgrest-js repo. Related to https://github.com/supabase/postgrest-js/issues/447 which was fixed recently. Could be combined with #523 and #520

encima avatar Mar 12 '24 08:03 encima

@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.

stefan-girlich avatar Apr 09 '24 13:04 stefan-girlich

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

bnjmnt4n avatar Apr 09 '24 16:04 bnjmnt4n

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.

stefan-girlich avatar Apr 10 '24 12:04 stefan-girlich