From 4130d20139b8b9f29da0503a0268d4903750e326 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 26 Feb 2024 11:17:48 +0000 Subject: [PATCH] fix: Update rpc return type (#702) --- supabase/_async/client.py | 10 +++++++--- supabase/_sync/client.py | 14 +++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/supabase/_async/client.py b/supabase/_async/client.py index 266a7c63..94df4259 100644 --- a/supabase/_async/client.py +++ b/supabase/_async/client.py @@ -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 @@ -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 @@ -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 diff --git a/supabase/_sync/client.py b/supabase/_sync/client.py index e761f819..faefc6c0 100644 --- a/supabase/_sync/client.py +++ b/supabase/_sync/client.py @@ -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 @@ -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 @@ -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