Skip to content

Commit 576987b

Browse files
authored
fix: head=True breaking count (#545)
1 parent 1e876b4 commit 576987b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

postgrest/base_request_builder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ def _get_count_from_http_request_response(
207207
def from_http_request_response(
208208
cls: Type[Self], request_response: RequestResponse
209209
) -> Self:
210+
count = cls._get_count_from_http_request_response(request_response)
210211
try:
211212
data = request_response.json()
212213
except JSONDecodeError:
213-
return cls(data=[], count=0)
214-
count = cls._get_count_from_http_request_response(request_response)
214+
data = request_response.text if len(request_response.text) > 0 else []
215215
# the type-ignore here is as pydantic needs us to pass the type parameter
216216
# here explicitly, but pylance already knows that cls is correctly parametrized
217217
return cls[_ReturnT](data=data, count=count) # type: ignore

0 commit comments

Comments
 (0)