Skip to content

fix(postgrest): escape quoted values in in filters - #1703

Merged
o-santi merged 1 commit into
supabase:mainfrom
hsusul:fix/postgrest-in-filter-escaping
Oct 9, 2026
Merged

o-santi merged 1 commit into
supabase:mainfrom
hsusul:fix/postgrest-in-filter-escaping

Conversation

@hsusul

@hsusul hsusul commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

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 ps cannot 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

@hsusul
hsusul requested review from a team and o-santi as code owners October 5, 2026 02:00
@o-santi
o-santi merged commit 710042f into supabase:main Oct 9, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

postgrest in_() does not escape quotes and backslashes in literal values

2 participants