Skip to content

Conversation

@7ttp
Copy link
Contributor

@7ttp 7ttp commented Dec 19, 2025

when reusing a PostgrestQueryBuilder instance returned by .from(),
url search params and headers were being shared across multiple operations,
causing filters to accumulate unexpectedly.
this fix ensures each operation receives its own cloned state.

fixes #1640

@7ttp 7ttp requested review from a team as code owners December 19, 2025 19:24
@7ttp 7ttp changed the title fix(postgrest): prevent shared state between query builder operations fix(postgrest-js): prevent shared state between query builder operations Dec 19, 2025
@coveralls
Copy link

coveralls commented Dec 19, 2025

Coverage Status

coverage: 81.006% (+0.01%) from 80.993%
when pulling 8d4ad19 on 7ttp:fix-postgrest-shared-state
into 5c06206 on supabase:master.

@7ttp 7ttp force-pushed the fix-postgrest-shared-state branch from 3422ca2 to da87e08 Compare December 19, 2025 19:57
@mandarini mandarini changed the title fix(postgrest-js): prevent shared state between query builder operations fix(postgrest): prevent shared state between query builder operations Jan 5, 2026
Copy link
Contributor

@mandarini mandarini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a regression test? Something like:

  it('should not share state between operations on same query builder', async () => {
    const table = postgrest.from('users');
    const q1 = table.select('*').eq('id', 1);
    const q2 = table.select('*').eq('id', 2);
    expect(q1.url.toString()).not.toContain('id=eq.2');
    expect(q2.url.toString()).not.toContain('id=eq.1');
  });

@mandarini mandarini self-assigned this Jan 5, 2026
@mandarini mandarini added the postgrest-js Related to the postgrest-js library. label Jan 7, 2026
@7ttp 7ttp force-pushed the fix-postgrest-shared-state branch from 1a7851d to 8d4ad19 Compare January 8, 2026 08:57
@7ttp
Copy link
Contributor Author

7ttp commented Jan 8, 2026

Added test for shared state isolation between query builder operations.
Ensures filters don't leak when reusing the same table reference.

@7ttp 7ttp requested a review from mandarini January 8, 2026 08:59
@mandarini mandarini merged commit cf0cc8a into supabase:master Jan 8, 2026
25 checks passed
@7ttp 7ttp deleted the fix-postgrest-shared-state branch January 9, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

postgrest-js Related to the postgrest-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected behavior for multiple operations on the same table

3 participants