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

fix(postgrest): preserve nullability when using JSON path

Open mandarini opened this issue 2 months ago • 2 comments

Original Author: @dev-hari-prasad Moved from: https://github.com/supabase/supabase-js/pull/1939

Description: What changed?
Fixed the type inference for JSON path selections (->) by adding | null when the underlying JSON column can be null.

Why was this change needed?
When selecting a JSON path from a nullable JSON column, the generated TypeScript types incorrectly assumed the value could never be null.
In reality, the runtime returns null when the whole column is null, so the types were unsafe.
This patch brings the inferred type in line with actual behavior.

Closes/Fixes #1635

mandarini avatar Jan 08 '26 13:01 mandarini

Coverage Status

coverage: 81.006%. remained the same when pulling 7bb36a5c4db9aa95b555e0ada1682524df1941e8 on fix/Null-should-be-included-in-return-type into cf0cc8a0895b0a45579d32832fc08e5a84934db3 on master.

coveralls avatar Jan 08 '26 13:01 coveralls

Open in StackBlitz

@supabase/auth-js

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

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

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

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

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

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

commit: 2d1bb73

pkg-pr-new[bot] avatar Jan 12 '26 03:01 pkg-pr-new[bot]

Just a feedback here, testing this out on some codebase result in some BC/bugs where things get infered as "null" only. Will work on making a MRE that can be added to the tests for it once I get the bandwidth for it.

avallete avatar Jan 28 '26 10:01 avallete