Skip to content

Commit 2241ee7

Browse files
committed
support insertion
1 parent 4617e4c commit 2241ee7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

supabase_py/lib/query_builder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@
1111
def _execute_monkey_patch(self) -> Dict[str, Any]:
1212
"""Temporary method to enable syncronous client code."""
1313
method: str = self.http_method.lower()
14+
additional_kwargs: Dict[str, Any] = {}
1415
if method == "get":
1516
func = requests.get
1617
elif method == "post":
1718
func = requests.post
19+
# Additionally requires the json body (e.g on insert, self.json==row).
20+
additional_kwargs = {"json": self.json}
1821
elif method == "put":
1922
func = requests.put
2023
elif method == "patch":
2124
func = requests.patch
2225
elif method == "delete":
2326
func = requests.delete
27+
else:
28+
raise NotImplementedError(f"Method '{method}' not recognised.")
2429
url: str = str(self.session.base_url).rstrip("/")
2530
query: str = str(self.session.params)
26-
response = func(f"{url}?{query}", headers=self.session.headers)
31+
response = func(f"{url}?{query}", headers=self.session.headers, **additional_kwargs)
2732
return {
2833
"data": response.json(),
2934
"status_code": response.status_code,

0 commit comments

Comments
 (0)