Skip to content
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

chore: add warnings to the manager #239

Merged
merged 1 commit into from
May 13, 2024
Merged
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
16 changes: 16 additions & 0 deletions peewee_async_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ async def my_async_func():

All will return `MyModel` instance with `id = 1`
"""
warnings.warn(
"`get` method is deprecated, use `AioModel.aio_get` instead.",
DeprecationWarning
)
await self.connect()

if isinstance(source_, peewee.Query):
Expand All @@ -252,6 +256,10 @@ async def my_async_func():

async def create(self, model_, **data):
"""Create a new object saved to database."""
warnings.warn(
"`create` method is deprecated, use `AioModel.aio_create` instead.",
DeprecationWarning
)
obj = model_(**data)
query = model_.insert(**dict(obj.__data__))

Expand All @@ -277,6 +285,10 @@ async def get_or_create(self, model_, defaults=None, **kwargs):

async def get_or_none(self, model_, *args, **kwargs):
"""Try to get an object and return None if it doesn't exist."""
warnings.warn(
"`get_or_none` method is deprecated, use `AioModel.aio_get_or_none` instead.",
DeprecationWarning
)
try:
return (await self.get(model_, *args, **kwargs))
except model_.DoesNotExist:
Expand Down Expand Up @@ -345,6 +357,10 @@ async def create_or_get(self, model_, **kwargs):

async def execute(self, query):
"""Execute query asyncronously."""
warnings.warn(
"`execute` method is deprecated, use `AioModel.aio_execute` or database.aio_execute instead.",
DeprecationWarning
)
return await self.database.aio_execute(query)

async def prefetch(self, query, *subqueries, prefetch_type=peewee.PREFETCH_TYPE.JOIN):
Expand Down
Loading