3
3
4
4
from httpx import Response
5
5
6
- from postgrest_py .constants import CountMethod , Filters , RequestMethod
6
+ from postgrest_py .types import CountMethod , Filters , RequestMethod , ReturnMethod
7
7
from postgrest_py .utils import (
8
8
AsyncClient ,
9
9
SyncClient ,
@@ -33,10 +33,11 @@ def pre_insert(
33
33
path : str ,
34
34
json : dict ,
35
35
* ,
36
- count : Optional [CountMethod ] = None ,
37
- upsert = False ,
36
+ count : Optional [CountMethod ],
37
+ returning : ReturnMethod ,
38
+ upsert : bool ,
38
39
) -> Tuple [RequestMethod , dict ]:
39
- prefer_headers = ["return=representation " ]
40
+ prefer_headers = [f "return={ returning } " ]
40
41
if count :
41
42
prefer_headers .append (f"count={ count } " )
42
43
if upsert :
@@ -50,8 +51,9 @@ def pre_upsert(
50
51
path : str ,
51
52
json : dict ,
52
53
* ,
53
- count : Optional [CountMethod ] = None ,
54
- ignore_duplicates = False ,
54
+ count : Optional [CountMethod ],
55
+ returning : ReturnMethod ,
56
+ ignore_duplicates : bool ,
55
57
) -> Tuple [RequestMethod , dict ]:
56
58
prefer_headers = ["return=representation" ]
57
59
if count :
@@ -67,9 +69,10 @@ def pre_update(
67
69
path : str ,
68
70
json : dict ,
69
71
* ,
70
- count : Optional [CountMethod ] = None ,
72
+ count : Optional [CountMethod ],
73
+ returning : ReturnMethod ,
71
74
) -> Tuple [RequestMethod , dict ]:
72
- prefer_headers = ["return=representation " ]
75
+ prefer_headers = [f "return={ returning } " ]
73
76
if count :
74
77
prefer_headers .append (f"count={ count } " )
75
78
session .headers ["prefer" ] = "," .join (prefer_headers )
@@ -80,9 +83,10 @@ def pre_delete(
80
83
session : Union [AsyncClient , SyncClient ],
81
84
path : str ,
82
85
* ,
83
- count : Optional [CountMethod ] = None ,
86
+ count : Optional [CountMethod ],
87
+ returning : ReturnMethod ,
84
88
) -> Tuple [RequestMethod , dict ]:
85
- prefer_headers = ["return=representation " ]
89
+ prefer_headers = [f "return={ returning } " ]
86
90
if count :
87
91
prefer_headers .append (f"count={ count } " )
88
92
session .headers ["prefer" ] = "," .join (prefer_headers )
0 commit comments