supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
1.03k stars 133 forks source link

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

Open thecoorum opened 6 months ago

thecoorum commented 6 months ago

Bug report

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

encima commented 6 months ago

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

stefan-girlich commented 5 months ago

@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 commented 5 months ago

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

stefan-girlich commented 5 months ago

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.