Skip to content

Commit

Permalink
fix: Update rpc return type (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Smith authored Feb 26, 2024
1 parent 9357140 commit 4130d20
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 7 additions & 3 deletions supabase/_async/client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import re
from typing import Any, Dict, Union
from typing import Any, Dict, Optional, Union

from gotrue import AsyncMemoryStorage
from gotrue.types import AuthChangeEvent, Session
from httpx import Timeout
from postgrest import (
AsyncFilterRequestBuilder,
AsyncPostgrestClient,
AsyncRequestBuilder,
AsyncRPCFilterRequestBuilder,
)
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
from storage3 import AsyncStorageClient
Expand Down Expand Up @@ -119,7 +119,9 @@ def from_(self, table_name: str) -> AsyncRequestBuilder:
"""
return self.postgrest.from_(table_name)

def rpc(self, fn: str, params: Dict[Any, Any]) -> AsyncFilterRequestBuilder:
def rpc(
self, fn: str, params: Optional[Dict[Any, Any]] = None
) -> AsyncRPCFilterRequestBuilder:
"""Performs a stored procedure call.
Parameters
Expand All @@ -135,6 +137,8 @@ def rpc(self, fn: str, params: Dict[Any, Any]) -> AsyncFilterRequestBuilder:
Returns a filter builder. This lets you apply filters on the response
of an RPC.
"""
if params is None:
params = {}
return self.postgrest.rpc(fn, params)

@property
Expand Down
14 changes: 11 additions & 3 deletions supabase/_sync/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import re
from typing import Any, Dict, Union
from typing import Any, Dict, Optional, Union

from gotrue import SyncMemoryStorage
from gotrue.types import AuthChangeEvent, Session
from httpx import Timeout
from postgrest import SyncFilterRequestBuilder, SyncPostgrestClient, SyncRequestBuilder
from postgrest import (
SyncPostgrestClient,
SyncRequestBuilder,
SyncRPCFilterRequestBuilder,
)
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
from storage3 import SyncStorageClient
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
Expand Down Expand Up @@ -115,7 +119,9 @@ def from_(self, table_name: str) -> SyncRequestBuilder:
"""
return self.postgrest.from_(table_name)

def rpc(self, fn: str, params: Dict[Any, Any]) -> SyncFilterRequestBuilder:
def rpc(
self, fn: str, params: Optional[Dict[Any, Any]] = None
) -> SyncRPCFilterRequestBuilder:
"""Performs a stored procedure call.
Parameters
Expand All @@ -131,6 +137,8 @@ def rpc(self, fn: str, params: Dict[Any, Any]) -> SyncFilterRequestBuilder:
Returns a filter builder. This lets you apply filters on the response
of an RPC.
"""
if params is None:
params = {}
return self.postgrest.rpc(fn, params)

@property
Expand Down

0 comments on commit 4130d20

Please sign in to comment.