fix(postgrest): normalize boolean values in is_() to lowercase literals#1535
Open
winklemad wants to merge 1 commit into
Open
fix(postgrest): normalize boolean values in is_() to lowercase literals#1535winklemad wants to merge 1 commit into
winklemad wants to merge 1 commit into
Conversation
`is_()` already converts Python `None` to the PostgREST literal `"null"`, but Python booleans fell through to `filter()`, which formats them as `is.True` / `is.False`. PostgREST's `is` operator is case-sensitive and only accepts lowercase `null`/`true`/`false`/`unknown`, so those requests are rejected by the server. Convert `True`/`False` to `"true"`/`"false"` (matching supabase-js, which emits `is.true`).
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.
No linked issue — found by reading the postgrest filter builder.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
is_()normalizes PythonNoneto the PostgREST literalnull, but does nothing for Python booleans. A boolean therefore falls through tofilter(), which formats it into the query string asis.True/is.False:PostgREST's
isoperator is case-sensitive and only accepts the lowercase trilean literalsnull,true,false,unknown(see PostgREST/postgrest#2077).is.Trueis rejected by the server, so.is_(col, True)/.is_(col, False)— the natural way to filter a boolean column againstIS TRUE/IS FALSE— produce a failing request.What is the new behavior?
is_()convertsTrue/Falseto"true"/"false", usingis True/is Falseidentity checks so only real booleans are touched — strings such as"unknown"/"not_null"and any other value pass through unchanged. This matches supabase-js, whose.is('col', true)emitsis.true.Additional context
The fix lives in the shared
base_request_builder.py, so it covers both the sync and async clients. Addedtest_is_true/test_is_false/test_is_noneto the postgrest filter-builder tests (_asyncand_sync). The full postgrest unit suite passes andruffcheck + format are clean.