Repository navigation
fix(postgrest): escape quoted values in in filters - #1703
Merged
Merged
Conversation
o-santi
approved these changes
Oct 9, 2026
This was referenced Oct 20, 2026
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.
Summary
Fixes #1702.
Escape embedded backslashes and double quotes when serializing values for PostgREST
in_()filters, and quote values containing either character. The shared helper fixes both public clients without generated-code changes.Problem and solution
Names such as
ACME, "Pro"were surrounded with quotes but emitted with unescaped contents, producing malformed filter grammar. Stored paths could also lose backslashes when parsed. Follow the PostgREST quoted-value rules, escaping backslashes before quotes.Tests and validation
The original request-level MockTransport regression failed for both sync and async clients on clean upstream
837cf3a, then passed with the fix. The expanded test covers quote-only values, backslashes, backslashes before quotes and unchanged simple/comma/colon/parenthesis/dotted values.From
src/postgrest:uv run --frozen --package postgrest pytest -q tests/test_in_filter.py: 10 passed.uv run --frozen --package postgrest pytest -q --ignore=tests/_async/test_filter_request_builder_integration.py --ignore=tests/_sync/test_filter_request_builder_integration.py: 276 passed.uv run --frozen --package postgrest mypy src/postgrest tests: clean, 31 source files.From the root:
uv run --frozen ruff check src/postgrest: clean.uv run --frozen ruff format --check src/postgrest: clean.uv build --package postgrest: wheel and sdist built.git diff --check: clean.Focused unchanged-upstream baseline: 124 passed. Full package
pytest -q --tb=no: 280 passed, 100 failures in live-service integration tests. Docker is not running (docker pscannot connect), so the Docker Compose/Postgres/PostgREST integration checks are not validated; no unrelated services were stopped or changed.Compatibility and related work
PostgREST only; one shared helper and request-level tests. Public signatures, return shapes, dotted-column handling, simple values and array-filter serialization are unchanged. No documentation or generated files need changes for this wire-format correction.
#1593 fixes PostgreSQL array-literal escaping and explicitly leaves
in_()out of scope. Historical postgrest-py #108 and #222 concern where quoting applies and dotted columns, not escaping quoted contents. Current and historical open/closed issue/PR searches, discussions, branches and field history found no blocking overlap.cc @olirice @silentworks