Skip to content

Commit 4130d20

Browse files
author
Andrew Smith
authored
fix: Update rpc return type (#702)
1 parent 9357140 commit 4130d20

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

supabase/_async/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import re
2-
from typing import Any, Dict, Union
2+
from typing import Any, Dict, Optional, Union
33

44
from gotrue import AsyncMemoryStorage
55
from gotrue.types import AuthChangeEvent, Session
66
from httpx import Timeout
77
from postgrest import (
8-
AsyncFilterRequestBuilder,
98
AsyncPostgrestClient,
109
AsyncRequestBuilder,
10+
AsyncRPCFilterRequestBuilder,
1111
)
1212
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
1313
from storage3 import AsyncStorageClient
@@ -119,7 +119,9 @@ def from_(self, table_name: str) -> AsyncRequestBuilder:
119119
"""
120120
return self.postgrest.from_(table_name)
121121

122-
def rpc(self, fn: str, params: Dict[Any, Any]) -> AsyncFilterRequestBuilder:
122+
def rpc(
123+
self, fn: str, params: Optional[Dict[Any, Any]] = None
124+
) -> AsyncRPCFilterRequestBuilder:
123125
"""Performs a stored procedure call.
124126
125127
Parameters
@@ -135,6 +137,8 @@ def rpc(self, fn: str, params: Dict[Any, Any]) -> AsyncFilterRequestBuilder:
135137
Returns a filter builder. This lets you apply filters on the response
136138
of an RPC.
137139
"""
140+
if params is None:
141+
params = {}
138142
return self.postgrest.rpc(fn, params)
139143

140144
@property

supabase/_sync/client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import re
2-
from typing import Any, Dict, Union
2+
from typing import Any, Dict, Optional, Union
33

44
from gotrue import SyncMemoryStorage
55
from gotrue.types import AuthChangeEvent, Session
66
from httpx import Timeout
7-
from postgrest import SyncFilterRequestBuilder, SyncPostgrestClient, SyncRequestBuilder
7+
from postgrest import (
8+
SyncPostgrestClient,
9+
SyncRequestBuilder,
10+
SyncRPCFilterRequestBuilder,
11+
)
812
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
913
from storage3 import SyncStorageClient
1014
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
@@ -115,7 +119,9 @@ def from_(self, table_name: str) -> SyncRequestBuilder:
115119
"""
116120
return self.postgrest.from_(table_name)
117121

118-
def rpc(self, fn: str, params: Dict[Any, Any]) -> SyncFilterRequestBuilder:
122+
def rpc(
123+
self, fn: str, params: Optional[Dict[Any, Any]] = None
124+
) -> SyncRPCFilterRequestBuilder:
119125
"""Performs a stored procedure call.
120126
121127
Parameters
@@ -131,6 +137,8 @@ def rpc(self, fn: str, params: Dict[Any, Any]) -> SyncFilterRequestBuilder:
131137
Returns a filter builder. This lets you apply filters on the response
132138
of an RPC.
133139
"""
140+
if params is None:
141+
params = {}
134142
return self.postgrest.rpc(fn, params)
135143

136144
@property

0 commit comments

Comments
 (0)