Skip to content

Commit fd842a1

Browse files
authored
Merge pull request #7 from supabase/feature/update-to-latest-gotrue-py
Update to latest gotrue-py, monkey patch for sync behaviour, add working tests
2 parents 23b944b + 1b0ebda commit fd842a1

File tree

9 files changed

+126
-306
lines changed

9 files changed

+126
-306
lines changed

.github/workflows/ci-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
poetry install
3030
- name: Test with Pytest
3131
run: |
32-
poetry run pytest
32+
SUPABASE_TEST_URL="https://tfsatoopsijgjhrqplra.supabase.co" SUPABASE_TEST_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxMjYwOTMyMiwiZXhwIjoxOTI4MTg1MzIyfQ.XL9W5I_VRQ4iyQHVQmjG0BkwRfx6eVyYB3uAKcesukg" poetry run pytest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
poetry.lock
2+
13
tags
24
## Vim stuff
35
# Swap

poetry.lock

Lines changed: 0 additions & 242 deletions
This file was deleted.

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
[tool.poetry]
22
name = "supabase-py"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
description = "Supabase client for Python."
55
authors = ["Joel Lee <[email protected]>"]
66
license = "MIT"
77

88
[tool.poetry.dependencies]
99
python = "^3.7.1"
10-
postgrest-py = "^0.3.2"
11-
realtime-py="^0.1.2"
12-
gotrue="0.1.2"
13-
pytest="6.2.2"
10+
postgrest-py = "0.4.0"
11+
realtime-py = "^0.1.2"
12+
gotrue = "0.2.0"
13+
pytest = "^6"
14+
requests = "2.25.1"
1415

1516
[tool.poetry.dev-dependencies]
1617

supabase_py/client.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"schema": "public",
1111
"auto_refresh_token": True,
1212
"persist_session": True,
13-
"detect_session_url": True,
13+
"detect_session_in_url": True,
1414
"local_storage": {},
1515
}
1616

@@ -60,7 +60,8 @@ def __init__(
6060
# )
6161
self.realtime = None
6262
self.postgrest: PostgrestClient = self._init_postgrest_client(
63-
rest_url=self.rest_url
63+
rest_url=self.rest_url,
64+
supabase_key=supabase_key,
6465
)
6566

6667
def table(self, table_name: str) -> SupabaseQueryBuilder:
@@ -70,20 +71,21 @@ def table(self, table_name: str) -> SupabaseQueryBuilder:
7071
this is a reserved keyword so we have elected to use the name `table`.
7172
Alternatively you can use the `._from()` method.
7273
"""
73-
return self._from(table_name)
74+
return self.from_(table_name)
7475

75-
def _from(self, table_name: str) -> SupabaseQueryBuilder:
76+
def from_(self, table_name: str) -> SupabaseQueryBuilder:
7677
"""Perform a table operation.
7778
7879
See the `table` method.
7980
"""
80-
return SupabaseQueryBuilder(
81+
query_builder = SupabaseQueryBuilder(
8182
url=f"{self.rest_url}/{table_name}",
8283
headers=self._get_auth_headers(),
8384
schema=self.schema,
8485
realtime=self.realtime,
8586
table=table_name,
8687
)
88+
return query_builder.from_(table_name)
8789

8890
def rpc(self, fn, params):
8991
"""Performs a stored procedure call.
@@ -143,28 +145,28 @@ def _init_realtime_client(
143145
def _init_supabase_auth_client(
144146
auth_url: str,
145147
supabase_key: str,
146-
detect_session_url: bool,
148+
detect_session_in_url: bool,
147149
auto_refresh_token: bool,
148150
persist_session: bool,
149151
local_storage: Dict[str, Any],
150152
headers: Dict[str, str],
151153
) -> SupabaseAuthClient:
152-
"""
153-
Private helper method for creating a wrapped instance of the GoTrue Client.
154-
"""
154+
"""Creates a wrapped instance of the GoTrue Client."""
155155
return SupabaseAuthClient(
156-
auth_url=auth_url,
156+
url=auth_url,
157157
auto_refresh_token=auto_refresh_token,
158-
detect_session_url=detect_session_url,
158+
detect_session_in_url=detect_session_in_url,
159159
persist_session=persist_session,
160160
local_storage=local_storage,
161161
headers=headers,
162162
)
163163

164164
@staticmethod
165-
def _init_postgrest_client(rest_url: str) -> PostgrestClient:
165+
def _init_postgrest_client(rest_url: str, supabase_key: str) -> PostgrestClient:
166166
"""Private helper for creating an instance of the Postgrest client."""
167-
return PostgrestClient(rest_url)
167+
client = PostgrestClient(rest_url)
168+
client.auth(token=supabase_key)
169+
return client
168170

169171
def _get_auth_headers(self) -> Dict[str, str]:
170172
"""Helper method to get auth headers."""
@@ -204,4 +206,3 @@ def create_client(supabase_url: str, supabase_key: str, **options) -> Client:
204206
Client
205207
"""
206208
return Client(supabase_url=supabase_url, supabase_key=supabase_key, **options)
207-

0 commit comments

Comments
 (0)