summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/asyncio/session.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-02 11:16:49 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-02 11:16:49 -0500
commit92e3272602723225e07dfa6e32b722ac439c713a (patch)
treee81577895d8d7a433493c8c5c1c8a0856b41afe4 /lib/sqlalchemy/ext/asyncio/session.py
parent6bea034dfc7e113baa6d728f6e2ae8324499ff4f (diff)
downloadsqlalchemy-92e3272602723225e07dfa6e32b722ac439c713a.tar.gz
convert AsyncSession.delete into awaitable
The API for :meth:`_asyncio.AsyncSession.delete` is now an awaitable; this method cascades along relationships which must be loaded in a similar manner as the :meth:`_asyncio.AsyncSession.merge` method. Fixes: #5998 Change-Id: Iae001efe99a1dcc47598b4a2491d17c4157fbbfa
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio/session.py')
-rw-r--r--lib/sqlalchemy/ext/asyncio/session.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py
index faa279cf9..93af178a3 100644
--- a/lib/sqlalchemy/ext/asyncio/session.py
+++ b/lib/sqlalchemy/ext/asyncio/session.py
@@ -28,7 +28,6 @@ T = TypeVar("T")
"__iter__",
"add",
"add_all",
- "delete",
"expire",
"expire_all",
"expunge",
@@ -223,6 +222,18 @@ class AsyncSession:
)
return _result.AsyncResult(result)
+ async def delete(self, instance):
+ """Mark an instance as deleted.
+
+ The database delete operation occurs upon ``flush()``.
+
+ As this operation may need to cascade along unloaded relationships,
+ it is awaitable to allow for those queries to take place.
+
+
+ """
+ return await greenlet_spawn(self.sync_session.delete, instance)
+
async def merge(self, instance, load=True):
"""Copy the state of a given instance into a corresponding instance
within this :class:`_asyncio.AsyncSession`.