From 14ea1bc4decc82c9278d231fa7de029447dccef4 Mon Sep 17 00:00:00 2001 From: Braedon Leonard Date: Wed, 10 Apr 2024 21:43:11 -0400 Subject: [PATCH] Fix issue with sqlalchemy cleanup deleting all unfinished schedules instead of finished schedules --- src/apscheduler/datastores/sqlalchemy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apscheduler/datastores/sqlalchemy.py b/src/apscheduler/datastores/sqlalchemy.py index 843dd7db4..ddc82ea86 100644 --- a/src/apscheduler/datastores/sqlalchemy.py +++ b/src/apscheduler/datastores/sqlalchemy.py @@ -963,7 +963,7 @@ async def cleanup(self) -> None: results = await self._execute(conn, query) if finished_schedule_ids := dict(results.all()): delete = self._t_schedules.delete().where( - ~self._t_schedules.c.id.in_(finished_schedule_ids) + self._t_schedules.c.id.in_(finished_schedule_ids) ) await self._execute(conn, delete)