Skip to content

postgrest: max_affected keeps conflicting handling and earlier limits #1826

Closed

Description

@ItsM0rty

max_affected() can send conflicting preferences that leave the intended limit unenforced.

With postgrest 2.33.0:

from postgrest import SyncPostgrestClient

client = SyncPostgrestClient(
    "https://example.com", headers={"Prefer": "handling=lenient"}
)
query = client.table("records").delete().max_affected(1)
print(query.request.headers["Prefer"])
# handling=lenient,handling=strict,max-affected=1

PostgREST uses the first occurrence of a preference. handling=lenient therefore wins, while max-affected requires strict handling. An application can ask for a one-row limit without the server applying that guard.

There is a second case without custom headers:

client = SyncPostgrestClient("https://example.com")
query = client.table("records").delete().max_affected(10).max_affected(1)
print(query.request.headers["Prefer"])
# return=representation,handling=strict,max-affected=10,max-affected=1

The earlier limit of 10 wins over the later limit of 1. This also affects updates and the async client.

Expected: one handling=strict preference and one max-affected preference containing the latest value. Other preferences should stay intact.

I reproduced the generated headers locally; no database requests were sent. PostgREST's parser documents its first-value behavior (link), and its maximum-affected reference explains the strict-handling requirement (link).

Activity

  1. added
    bug
    python
    PostgREST
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PostgRESTbugpython

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions