Skip to content

Fix/postgrest not null narrowing#2028

Open
DevanshTyagi04 wants to merge 2 commits intosupabase:masterfrom
DevanshTyagi04:fix/postgrest-not-null-narrowing
Open

Fix/postgrest not null narrowing#2028
DevanshTyagi04 wants to merge 2 commits intosupabase:masterfrom
DevanshTyagi04:fix/postgrest-not-null-narrowing

Conversation

@DevanshTyagi04
Copy link
Copy Markdown

Improves TypeScript type inference for PostgREST filters by correctly narrowing column types after explicit non-null checks.

What changed?

  • Added a specialized overload for not(column, 'is', null) in PostgrestFilterBuilder
  • Ensured that when a column is filtered to exclude NULL, the resulting row type marks that column as non-nullable
  • Preserved existing behavior for all other not() filter usages

Why was this change needed?

Previously, filtering out NULL values using not(column, 'is', null) did not update the inferred row type, leaving the column typed as nullable.
This caused a mismatch between PostgREST semantics and TypeScript inference.

This change aligns the type system with runtime behavior and improves developer ergonomics.

Closes #1360

📸 Screenshots/Examples

// Before
const { data } = await supabase
  .from('users')
  .select()
  .not('email', 'is', null)

// email: string | null ❌

// After
// email: string ✅

@DevanshTyagi04 DevanshTyagi04 requested review from a team as code owners January 17, 2026 17:36
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 80.997%. remained the same
when pulling 25e4da5 on DevanshTyagi04:fix/postgrest-not-null-narrowing
into 09aa106 on supabase:master.

@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale because it has not had activity for 90 days.
It will be closed in 14 days if no further activity occurs.

Please rebase and update if this is still needed.

@github-actions github-actions bot added the stale label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inferred types for nullable columns after not null checks should be non-nullable

2 participants