Skip to content

Commit 32f9fba

Browse files
committed
Deprecate PostgrestClient.from_table()
1 parent 4f2accb commit 32f9fba

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#### Changed
1414

1515
- Rename `Client` to `PostgrestClient` and deprecate the old name
16+
- Deprecate `PostgrestClient.from_table()`
1617

1718
#### Removed
1819

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ from postgrest_py import PostgrestClient
3030

3131
async def main():
3232
async with PostgrestClient("http://localhost:3000") as client:
33-
r = await client.from_table("countries").select("*")
33+
r = await client.from_("countries").select("*")
3434
countries = r.json()
3535

3636
asyncio.run(main())
@@ -39,7 +39,7 @@ asyncio.run(main())
3939
### Create
4040

4141
```py
42-
await client.from_table("countries").insert({
42+
await client.from_("countries").insert({
4343
"name": "Việt Nam",
4444
"capital": "Hà Nội",
4545
})
@@ -48,7 +48,7 @@ await client.from_table("countries").insert({
4848
### Read
4949

5050
```py
51-
r = await client.from_table("countries").select("id", "name")
51+
r = await client.from_("countries").select("id", "name")
5252
countries = r.json()
5353
```
5454

postgrest_py/client.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ def schema(self, schema: str):
3939
)
4040
return self
4141

42-
def from_table(self, table: str) -> RequestBuilder:
42+
def from_(self, table: str) -> RequestBuilder:
4343
return RequestBuilder(self.session, f"/{table}")
4444

45-
def from_(self, table: str) -> RequestBuilder:
46-
"""Alias to Self.from_table()."""
45+
@deprecated("0.2.0", "1.0.0", __version__, "Use PostgrestClient.from_() instead")
46+
def from_table(self, table: str) -> RequestBuilder:
47+
"""Alias to Self.from_()."""
4748

48-
return self.from_table(table)
49+
return self.from_(table)
4950

5051
async def rpc(self, func: str, params: dict) -> Response:
5152
"""Execute a stored procedure call."""

0 commit comments

Comments
 (0)