You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostgREST 11.2.0 introduced stripping of null value properties in JSON results for arrays and single object responses. To support that functionality in postgrest-js a method like stripNulls()could be introduced. For instance: client.from('table').select().stripNulls().
The text was updated successfully, but these errors were encountered:
steve-chavez
changed the title
PostgREST 11.2.0 introduced stripping of null value properties in JSON results for arrays and single object responses. To support that functionality in [postgrest-js](https://github.com/supabase/postgrest-js) a method like stripNulls()could be introduced. For instance: client.from('table').select().stripNulls().
Support nulls=stripped introduced by PostgREST 11.2.0
Aug 14, 2023
If anyone already needs this before we've got a method for this, you can tune your supabase instance to skip nulls for array responses (e.g. for a specific rpc) like this:
exportconstsupabase=createClient(URL,ANON_KEY,{global: {fetch: (request,init)=>{// Use any condition here to determine if the requests should skip nulls:constshouldStripNulls=request.toString().includes('rpc/your-rpc-call');if(shouldStripNulls){constheaders=newHeaders(init?.headers);headers.set('Accept','application/vnd.pgrst.array+json;nulls=stripped');returnfetch(request,{ ...init, headers });}returnfetch(request,init);},},},);
I had some requests with lots of optional columns, cut down the response size by ~50% 👍
PostgREST 11.2.0 introduced stripping of null value properties in JSON results for arrays and single object responses. To support that functionality in postgrest-js a method like
stripNulls()
could be introduced. For instance:client.from('table').select().stripNulls()
.Further information:
https://github.com/PostgREST/postgrest/releases/tag/v11.2.0 (see "Resource Representation")
https://postgrest.org/en/stable/references/api/resource_representation.html#stripped-nulls
https://github.com/PostgREST/postgrest/blob/main/test/spec/Feature/Query/NullsStrip.hs
PostgREST/postgrest#1601
PostgREST/postgrest#2894
PostgREST/postgrest#2899
Originally posted by @vrilcode in supabase/supabase#16479
The text was updated successfully, but these errors were encountered: