Skip to content

fix(postgrest): use params.set() for limit/offset/range — setter semantics - #1618

Open
abhi-0203 wants to merge 1 commit into
supabase:mainfrom
abhi-0203:fix/limit-offset-range-setter-semantics
Open

fix(postgrest): use params.set() for limit/offset/range — setter semantics#1618
abhi-0203 wants to merge 1 commit into
supabase:mainfrom
abhi-0203:fix/limit-offset-range-setter-semantics

Conversation

@abhi-0203

Copy link
Copy Markdown

Summary

limit(), offset(), and range() used params.add() which allows duplicate keys, so calling them twice sends duplicate query params (limit=10&limit=20). httpx uses the last value server-side, but the client sees the first value when reading back — an inconsistency trap.

The fix changes all three methods to use params.set(), matching how order() already works.

Changes

src/postgrest/src/postgrest/base_request_builder.py:

  • limit(): params.add()params.set()
  • offset(): params.add()params.set()
  • range(): params.add()params.set() (both offset and limit)

Verification

q = client.from_("t").select("*").limit(10).limit(20)
# Before: select=*&limit=10&limit=20
# After:  select=*&limit=20

Closes #1617

…fset/range

Fixes duplicate query params when limit()/offset()/range() called multiple times.

Before: .limit(10).limit(20) sent limit=10&limit=20 (httpx uses last, client sees first)
After: .limit(10).limit(20) sends limit=20 (consistent with order() behavior)

Closes supabase#1617
@abhi-0203
abhi-0203 requested review from a team and o-santi as code owners September 6, 2026 04:32
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.

Calling limit()/offset()/range() twice sends duplicate query params

1 participant