1
1
from __future__ import annotations
2
2
3
- from typing import Optional
3
+ from json import JSONDecodeError
4
+ from typing import Optional , Union
4
5
5
6
from httpx import Headers , QueryParams
6
7
from pydantic import ValidationError
17
18
pre_update ,
18
19
pre_upsert ,
19
20
)
20
- from ..exceptions import APIError
21
+ from ..exceptions import APIError , generate_default_error_message
21
22
from ..types import ReturnMethod
22
23
from ..utils import SyncClient
23
24
@@ -67,6 +68,8 @@ def execute(self) -> APIResponse:
67
68
raise APIError (r .json ())
68
69
except ValidationError as e :
69
70
raise APIError (r .json ()) from e
71
+ except JSONDecodeError as e :
72
+ raise APIError (generate_default_error_message (r ))
70
73
71
74
72
75
class SyncSingleRequestBuilder :
@@ -114,6 +117,8 @@ def execute(self) -> SingleAPIResponse:
114
117
raise APIError (r .json ())
115
118
except ValidationError as e :
116
119
raise APIError (r .json ()) from e
120
+ except JSONDecodeError as e :
121
+ raise APIError (generate_default_error_message (r ))
117
122
118
123
119
124
class SyncMaybeSingleRequestBuilder (SyncSingleRequestBuilder ):
@@ -220,7 +225,7 @@ def select(
220
225
*columns: The names of the columns to fetch.
221
226
count: The method to use to get the count of rows returned.
222
227
Returns:
223
- :class:`SyncSelectRequestBuilder `
228
+ :class:`AsyncSelectRequestBuilder `
224
229
"""
225
230
method , params , headers , json = pre_select (* columns , count = count )
226
231
return SyncSelectRequestBuilder (
@@ -229,7 +234,7 @@ def select(
229
234
230
235
def insert (
231
236
self ,
232
- json : dict ,
237
+ json : Union [ dict , list ] ,
233
238
* ,
234
239
count : Optional [CountMethod ] = None ,
235
240
returning : ReturnMethod = ReturnMethod .representation ,
@@ -243,7 +248,7 @@ def insert(
243
248
returning: Either 'minimal' or 'representation'
244
249
upsert: Whether the query should be an upsert.
245
250
Returns:
246
- :class:`SyncQueryRequestBuilder `
251
+ :class:`AsyncQueryRequestBuilder `
247
252
"""
248
253
method , params , headers , json = pre_insert (
249
254
json ,
@@ -273,7 +278,7 @@ def upsert(
273
278
ignore_duplicates: Whether duplicate rows should be ignored.
274
279
on_conflict: Specified columns to be made to work with UNIQUE constraint.
275
280
Returns:
276
- :class:`SyncQueryRequestBuilder `
281
+ :class:`AsyncQueryRequestBuilder `
277
282
"""
278
283
method , params , headers , json = pre_upsert (
279
284
json ,
@@ -300,7 +305,7 @@ def update(
300
305
count: The method to use to get the count of rows returned.
301
306
returning: Either 'minimal' or 'representation'
302
307
Returns:
303
- :class:`SyncFilterRequestBuilder `
308
+ :class:`AsyncFilterRequestBuilder `
304
309
"""
305
310
method , params , headers , json = pre_update (
306
311
json ,
@@ -323,7 +328,7 @@ def delete(
323
328
count: The method to use to get the count of rows returned.
324
329
returning: Either 'minimal' or 'representation'
325
330
Returns:
326
- :class:`SyncFilterRequestBuilder `
331
+ :class:`AsyncFilterRequestBuilder `
327
332
"""
328
333
method , params , headers , json = pre_delete (
329
334
count = count ,
0 commit comments