Skip to content

fix(postgrest): add missing count, head, and get params #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions supabase/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
AsyncRPCFilterRequestBuilder,
)
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
from postgrest.types import CountMethod
from realtime import AsyncRealtimeChannel, AsyncRealtimeClient, RealtimeChannelOptions
from storage3 import AsyncStorageClient
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
Expand Down Expand Up @@ -139,7 +140,12 @@ def from_(self, table_name: str) -> AsyncRequestBuilder:
return self.postgrest.from_(table_name)

def rpc(
self, fn: str, params: Optional[Dict[Any, Any]] = None
self,
fn: str,
params: Optional[Dict[Any, Any]] = None,
count: Optional[CountMethod] = None,
head: bool = False,
get: bool = False,
) -> AsyncRPCFilterRequestBuilder:
"""Performs a stored procedure call.

Expand All @@ -149,6 +155,9 @@ def rpc(
The stored procedure call to be executed.
params : dict of any
Parameters passed into the stored procedure call.
count: The method to use to get the count of rows returned.
head: When set to `true`, `data` will not be returned. Useful if you only need the count.
get: When set to `true`, the function will be called with read-only access mode.

Returns
-------
Expand All @@ -158,7 +167,7 @@ def rpc(
"""
if params is None:
params = {}
return self.postgrest.rpc(fn, params)
return self.postgrest.rpc(fn, params, count, head, get)

@property
def postgrest(self):
Expand Down
13 changes: 11 additions & 2 deletions supabase/_sync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
SyncRPCFilterRequestBuilder,
)
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
from postgrest.types import CountMethod
from realtime import RealtimeChannelOptions, SyncRealtimeChannel, SyncRealtimeClient
from storage3 import SyncStorageClient
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
Expand Down Expand Up @@ -138,7 +139,12 @@ def from_(self, table_name: str) -> SyncRequestBuilder:
return self.postgrest.from_(table_name)

def rpc(
self, fn: str, params: Optional[Dict[Any, Any]] = None
self,
fn: str,
params: Optional[Dict[Any, Any]] = None,
count: Optional[CountMethod] = None,
head: bool = False,
get: bool = False,
) -> SyncRPCFilterRequestBuilder:
"""Performs a stored procedure call.

Expand All @@ -148,6 +154,9 @@ def rpc(
The stored procedure call to be executed.
params : dict of any
Parameters passed into the stored procedure call.
count: The method to use to get the count of rows returned.
head: When set to `true`, `data` will not be returned. Useful if you only need the count.
get: When set to `true`, the function will be called with read-only access mode.

Returns
-------
Expand All @@ -157,7 +166,7 @@ def rpc(
"""
if params is None:
params = {}
return self.postgrest.rpc(fn, params)
return self.postgrest.rpc(fn, params, count, head, get)

@property
def postgrest(self):
Expand Down