Consider the first "Operator Modifiers" example from https://postgrest.org/en/stable/references/api/tables_views.html#operator-modifiers:
curl "http://localhost:3000/people?last_name=like(any).{O*,P*}"
If I try to replicate it using httpx (or requests, urllib3 or any other Python module I tried) the URL that ends up at PostgREST's end is urlencoded:
>>> import https
>>> r = httpx.get("http://localhost:3000/people?last_name=like(any).{O*,P*}")
>>> print(r.url)
URL('http://localhost:3000/people?last_name=like(any).%7BO*,P*%7D')
PostgREST responds with an error to that:
{'code': '22P02',
'details': 'Expected ":", but found "}".',
'hint': None,
'message': 'invalid input syntax for type json'}
It does not seem possible to disable the automatic urlencoding on the client's end.
How can I query PostgREST using httpx?
The issue here has nothing to do with URL encoding. URL encoding is required by the standard, and if postgrest actually had a problem with that it would be buggy.
The problem is that your
curlcommand line doesn't do what you think it does.curltreats a{a,b,c}expression a bit like the shell: it will expand it into multiple distinct URLs. So when you write:Your are effectively running multiple
curlcommands:This is described in the "Globbing" section of the curl man page.
I think you will find that you can request either of the above URLs using
httpx(etc) without a problem.You can verify the above by running
curlwith the--trace-ascii logoption, and then inspecting the resultinglogfile. You will see multipleGETrequests.You can disable globbing with the
--globoff(-g) option.