Skip to content

fix(postgrest): type rpc() with count but no head as the filter builder - #2053

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2975-postgrest-rpccsv-parses-the-csv-body
Nov 16, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2975-postgrest-rpccsv-parses-the-csv-body

Conversation

@spydon

@spydon spydon commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

rpc(..., count=...) without head is typed as RPCFilterRequestBuilder, so rpc(..., count=...).csv() type-checks. It also adds the integration and type-check coverage SDK-2975 asked for. #2051 already made rpc().csv() return a TextRequestBuilder.

Changes

  • The rpc() overloads of PostgrestClient are reduced to the three SupabaseClient uses: head=False (the default) gives RPCFilterRequestBuilder, head=True gives RPCCountRequestBuilder, and a plain bool gives the union. Before, a call with only count= fell through to the catch-all overload and was typed as the union, which has no csv().
  • New type-check fixture tests/typecheck/rpc.py, checked with mypy, pyright and pyrefly: rpc(...).csv() and its TextAPIResponse for both clients, count= with and without head=True, and the rejected chains after csv() and csv() on the count builder.
  • Integration tests in tests/_async and tests/_sync that call a function with .csv() against the local stack.

Fixes SDK-2975

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 604ec6e7-b6bd-46e2-b1af-023a330eeb56
Commits

Reviewing files that changed from the base of the PR and between 50f1b22 and 4badb09.

Files selected for processing: 4

  • src/postgrest/src/postgrest/client.py
  • src/postgrest/tests/_async/test_filter_request_builder_integration.py
  • src/postgrest/tests/_sync/test_filter_request_builder_integration.py
  • src/postgrest/tests/typecheck/rpc.py

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • RPC calls can now return CSV as plain text, with selection and query modifiers applied before requesting CSV output.
  • Bug Fixes
    • CSV RPC responses are returned directly as text instead of being wrapped in a structured RPC response.
  • Documentation
    • Updated guidance to clarify CSV return behavior and that head=True RPC calls do not support CSV output.

RPC CSV requests now use RPCFilterRequestBuilder.csv(), which returns a TextRequestBuilder. Executing that builder returns CSV response text rather than an RPCResponse. The change updates the migration guidance and compliance registry, and adds synchronous, asynchronous, integration, and type-checking coverage.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant RPCFilterRequestBuilder
  participant TextRequestBuilder
  participant RPCEndpoint
  Caller->>RPCFilterRequestBuilder: Call csv()
  RPCFilterRequestBuilder->>TextRequestBuilder: Return builder with executor, URL, and headers
  Caller->>TextRequestBuilder: Call execute()
  TextRequestBuilder->>RPCEndpoint: Send CSV request
  RPCEndpoint-->>TextRequestBuilder: Return CSV response body
  TextRequestBuilder-->>Caller: Return response text
Loading

Change: Bug fix

Merge Risk: Minimal · previous review 50f1b

rpc().csv() now returns a text builder whose execute() yields a CSV string, which is a documented breaking change recorded in MIGRATION.md. I found no remaining merge-blocking risk.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9c609e04-8532-416d-823a-24e6008d9cd3
Commits

Reviewing files that changed from the base of the PR and between ccb6e1a and 50f1b22.

Files selected for processing: 4

  • MIGRATION.md
  • src/postgrest/src/postgrest/client.py
  • src/postgrest/src/postgrest/request_builder.py
  • src/postgrest/tests/typecheck/rpc.py
Files skipped from review as they are similar to previous changes: 1

  • src/postgrest/src/postgrest/request_builder.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

@spydon
spydon force-pushed the lukasklingsbo/sdk-2975-postgrest-rpccsv-parses-the-csv-body branch from 50f1b22 to 4badb09 Compare November 13, 2026 16:47
@spydon spydon changed the title fix(postgrest)!: return a text builder from rpc().csv() fix(postgrest): type rpc() with count but no head as the filter builder Nov 13, 2026
@spydon
spydon merged commit 8323a9f into main Nov 16, 2026
28 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2975-postgrest-rpccsv-parses-the-csv-body branch November 16, 2026 08:54
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.

1 participant