Skip to content

feat(postgrest): add stripNulls method for null value stripping#2189

Open
TheSeydiCharyyev wants to merge 3 commits intosupabase:masterfrom
TheSeydiCharyyev:feat/strip-nulls
Open

feat(postgrest): add stripNulls method for null value stripping#2189
TheSeydiCharyyev wants to merge 3 commits intosupabase:masterfrom
TheSeydiCharyyev:feat/strip-nulls

Conversation

@TheSeydiCharyyev
Copy link
Copy Markdown

@TheSeydiCharyyev TheSeydiCharyyev commented Mar 25, 2026

Description

Adds a stripNulls() method to the PostgREST query builder, enabling null value stripping from JSON responses via the PostgREST nulls=stripped media type parameter.

Related Issue

Resolves supabase/postgrest-js#460

How it works

  • Adds a shouldStripNulls flag to PostgrestBuilder
  • The stripNulls() method sets this flag
  • In .then(), before fetch, the Accept header is modified:
    • Array responses: application/vnd.pgrst.array+json;nulls=stripped
    • Single object responses: application/vnd.pgrst.object+json;nulls=stripped
    • Other formats (CSV, GeoJSON) are not affected

Usage

const { data } = await supabase.from('users').select().stripNulls()
const { data } = await supabase.from('users').select().eq('id', 1).single().stripNulls()

Requires PostgREST 11.2.0+.

Testing

- 3 new tests added (array, single, csv-compatibility)
- All 303 existing tests pass
- Build passes

Checklist

- Code formatted
- Tests passing
- Builds passing
- Used conventional commits

@TheSeydiCharyyev TheSeydiCharyyev requested review from a team as code owners March 25, 2026 06:05
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 25, 2026

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2189

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2189

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2189

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2189

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2189

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2189

commit: 4dc6486

test('stripNulls does not affect csv', async () => {
const res = await postgrest.from('users').select().csv().stripNulls()
expect(res.error).toBeNull()
// CSV format should still work — stripNulls is ignored for non-JSON formats
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about failing instead when stripNulls is chained with csv?

@TheSeydiCharyyev
Copy link
Copy Markdown
Author

Good idea, will make it throw an error instead. Pushing a fix soon.

@TheSeydiCharyyev
Copy link
Copy Markdown
Author

Updated — stripNulls() now throws immediately when chained after csv(). Tests pass locally (305/310, 5 unrelated env failures).

@mandarini mandarini requested a review from steve-chavez March 26, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support nulls=stripped introduced by PostgREST 11.2.0

2 participants