Skip to content

feat(postgrest): add explicit .clone() method for safe query branching - #1625

Open
Vishv07 wants to merge 1 commit into
supabase:mainfrom
Vishv07:feat/postgrest-builder-clone
Open

Vishv07 wants to merge 1 commit into
supabase:mainfrom
Vishv07:feat/postgrest-builder-clone

Conversation

@Vishv07

@Vishv07 Vishv07 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements explicit .clone() method across PostgREST query and filter request builders for safe query branching without in-place mutation.

Motivation

As discussed in supabase/supabase#50049 and issue #1208, builders mutate internal state in-place. .clone() provides an ergonomic way to branch queries (pagination, total counts, dynamic filtering) without breaking backwards compatibility.

Changes

  • Added .clone() to RequestConfig and BaseFilterRequestBuilder (deep-copies headers, params, JSON payloads).
  • Added .clone() to all async and sync request builders.
  • Added unit tests for filter and query builder isolation.

Fixes #1208
Ref: supabase/supabase#50049

…branching

- Add .clone() to RequestConfig and BaseFilterRequestBuilder deep-copying headers, params, and json
- Add .clone() to AsyncRequestBuilder, AsyncQueryRequestBuilder, AsyncSingleRequestBuilder, AsyncExplainRequestBuilder, AsyncMaybeSingleRequestBuilder
- Generate sync counterparts via run-unasync.py
- Add unit tests for filter and query builder clone isolation and branching

Fixes supabase#1208
Ref: supabase/supabase#50049
@Vishv07
Vishv07 requested review from a team and o-santi as code owners September 8, 2026 17:27
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.

Query builder queries are not immutable

1 participant