Repository navigation
fix(postgrest): port small v2 request fixes - #2050
Conversation
Return no count when PostgREST reports an unknown total, replace earlier max-affected and handling preferences, reject a non-http base_url, and send GET and HEAD requests without a body.
|
No actionable comments were generated in the recent review. Summary
Change: Bug fix Merge Risk:
|
Why
Four small postgrest request bugs that v2 already fixed, or that turned up while auditing, are still in v3.
What changed
count="planned"or"estimated", PostgREST can answer with*as the total inContent-Range. The response parser calledint()on it and raisedValueErrorafter the write had committed. It now returns no count, as v2 does (fix(postgrest): return no count when the total is unknown #1892).max_affected()preferences. Each call appendedhandling=strictandmax-affected=toPrefer, so calling it twice sent both twice. It now drops earlierhandling=andmax-affected=preferences, including ones packed into a comma-separated value, and keeps the others (fix(postgrest): replace conflicting max-affected preferences #1827, SDK-1704).base_urlcheck.is_http_urlexisted but was never called, so a client acceptedftp://or an empty URL and failed only at the first request.PostgrestClient.__init__now raisesValueErrorfor a URL that is not http or https, or that has no host (fix(postgrest): raise on a non-http base_url #1881, SDK-1667).select()andrpc(get=True)orrpc(head=True)sent{}withContent-Type: application/jsononGETandHEAD.delete()sent the same empty body.PostgrestRequest.finalizenow sendsGET,HEADandDELETEwithout a body or content type. Writes with a payload still send their JSON body.Tests
test_unknown_count.py: the header parser and an insert with a*/*total, forplannedandestimated.test_filter_builder.py:max_affected()called twice, and replacing an existinghandling=preference. The existing test that expected a duplicatehandling=strictnow expects one.test_client_base_url.py: the sync and async clients reject non-http URLs andhttp://without a host, and accept http and https.test_bodyless_requests.py: select, head select, rpc GET, rpc HEAD and delete send no body or content type. An insert still sends JSON.The new tests fail without the source changes.
The related
schema()bug, where profile headers are appended instead of replaced, is tracked separately in SDK-2758.SDK-2824