Skip to content

Commit 8f1300e

Browse files
authored
fix: schema access optimization (#966)
1 parent fcea7f4 commit 8f1300e

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

supabase/_async/client.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,11 @@ def schema(self, schema: str) -> AsyncPostgrestClient:
129129
130130
The schema needs to be on the list of exposed schemas inside Supabase.
131131
"""
132-
self._postgrest = self._init_postgrest_client(
133-
rest_url=self.rest_url,
134-
headers=self.options.headers,
135-
schema=schema,
136-
timeout=self.options.postgrest_client_timeout,
137-
)
138-
return self._postgrest
132+
if self.options.schema != schema:
133+
self.options.schema = schema
134+
if self._postgrest:
135+
self._postgrest.schema(schema)
136+
return self.postgrest
139137

140138
def from_(self, table_name: str) -> AsyncRequestBuilder:
141139
"""Perform a table operation.

supabase/_sync/client.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,11 @@ def schema(self, schema: str) -> SyncPostgrestClient:
128128
129129
The schema needs to be on the list of exposed schemas inside Supabase.
130130
"""
131-
self._postgrest = self._init_postgrest_client(
132-
rest_url=self.rest_url,
133-
headers=self.options.headers,
134-
schema=schema,
135-
timeout=self.options.postgrest_client_timeout,
136-
)
137-
return self._postgrest
131+
if self.options.schema != schema:
132+
self.options.schema = schema
133+
if self._postgrest:
134+
self._postgrest.schema(schema)
135+
return self.postgrest
138136

139137
def from_(self, table_name: str) -> SyncRequestBuilder:
140138
"""Perform a table operation.

0 commit comments

Comments
 (0)