diff --git a/supabase/_async/client.py b/supabase/_async/client.py index 666571f1..ad21c7cd 100644 --- a/supabase/_async/client.py +++ b/supabase/_async/client.py @@ -129,13 +129,11 @@ def schema(self, schema: str) -> AsyncPostgrestClient: The schema needs to be on the list of exposed schemas inside Supabase. """ - self._postgrest = self._init_postgrest_client( - rest_url=self.rest_url, - headers=self.options.headers, - schema=schema, - timeout=self.options.postgrest_client_timeout, - ) - return self._postgrest + if self.options.schema != schema: + self.options.schema = schema + if self._postgrest: + self._postgrest.schema(schema) + return self.postgrest def from_(self, table_name: str) -> AsyncRequestBuilder: """Perform a table operation. diff --git a/supabase/_sync/client.py b/supabase/_sync/client.py index f3ed2ba6..680a7aea 100644 --- a/supabase/_sync/client.py +++ b/supabase/_sync/client.py @@ -128,13 +128,11 @@ def schema(self, schema: str) -> SyncPostgrestClient: The schema needs to be on the list of exposed schemas inside Supabase. """ - self._postgrest = self._init_postgrest_client( - rest_url=self.rest_url, - headers=self.options.headers, - schema=schema, - timeout=self.options.postgrest_client_timeout, - ) - return self._postgrest + if self.options.schema != schema: + self.options.schema = schema + if self._postgrest: + self._postgrest.schema(schema) + return self.postgrest def from_(self, table_name: str) -> SyncRequestBuilder: """Perform a table operation.