supabase / postgrest-js

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

.explain() method always return error #504

Closed fdgtalk closed 10 months ago

fdgtalk commented 10 months ago

Bug report

Describe the bug

Chaining the .explain() method to a working query, return this error:

error: {
    code: '42883',
    details: null,
    hint: 'No function matches the given name and argument types. You might need to add explicit type casts.',
    message: 'function string_agg(record, unknown) does not exist'
  } 

To Reproduce

Following the official guide: https://supabase.com/docs/guides/api/rest/debugging-performance

Run this SQL command:

alter role authenticator set pgrst.db_plan_enabled to 'true';
NOTIFY pgrst, 'reload config'; 

Query some data:

const data = await supabase.from('countries').select('*').explain()
console.log(data)

Expected behavior

Response similar to this:

Aggregate  (cost=33.34..33.36 rows=1 width=112)
  ->  Limit  (cost=0.00..18.33 rows=1000 width=40)
        ->  Seq Scan on countries  (cost=0.00..22.00 rows=1200 width=40) 

Additional context

I've tried with /supabase-js & /ssr

steve-chavez commented 10 months ago

A bug in postgrest-js, somehow it's sending an undefined:

Accept: application/vnd.pgrst.plan+text; for="undefined"; options=;

On https://github.com/supabase/postgrest-js/blob/master/src/PostgrestTransformBuilder.ts#L245-L276


PostgREST v12 will also give a better error message for this case.

github-actions[bot] commented 10 months ago

:tada: This issue has been resolved in version 1.8.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket: