fix(postgrest): add type safety for eq() and neq() column names#2175
Merged
mandarini merged 2 commits intosupabase:masterfrom Mar 23, 2026
Merged
fix(postgrest): add type safety for eq() and neq() column names#2175mandarini merged 2 commits intosupabase:masterfrom
mandarini merged 2 commits intosupabase:masterfrom
Conversation
0dc4012 to
5762d1f
Compare
Add overloads to eq() and neq() matching gt/gte/lt/lte pattern: - Strict overload: column must extend keyof Row for autocomplete and invalid column name detection - Fallback overload: column: string for dynamic usage Fixes supabase/supabase#43381
5762d1f to
9325928
Compare
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
steve-chavez
approved these changes
Mar 23, 2026
Member
steve-chavez
left a comment
There was a problem hiding this comment.
LGTM 👍. Essentially ensuring the first arg of the eq() is always a column name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes supabase/supabase#43381, Adds type safety to eq() and neq() for column names.
Builds on the original approach from @aayushbaluni, but uses a conditional type on the column parameter instead of overloads. The overload pattern doesn't actually reject invalid literals, they silently fall through to the
eq(column: string, value: unknown)fallback. The conditional type approach closes that hole.How it works:
.eq('username', 'foo').eq('INVALID', 'x').eq('users.status', 'ONLINE').eq('bar->version', 31)const col: string; .eq(col, x)Also fixes a latent type error in
relationships-error-handling.test.tswhere.eq('id', 2)was called on the users table (which has no id column). This was previously masked by the fallback overload.