Python: Limit the rows an update or delete affects

Set the maximum number of rows that can be affected by an update or delete operation. If the query would affect more rows than the specified limit, the operation will fail with an error.

This uses PostgREST's Prefer: max-affected header with handling=strict.

Parameters

Examples

Limit affected rows on update

response = (
    supabase.table("planets")
    .update({"name": "Updated"})
    .eq("id", 1)
    .max_affected(1)
    .execute()
)

Limit affected rows on delete

response = (
    supabase.table("planets")
    .delete()
    .eq("id", 1)
    .max_affected(1)
    .execute()
)