From aee17426505bf4857c62f5300f007fba04cdd1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Mon, 11 Jan 2021 01:29:59 +0200 Subject: Fixed potential where clause error in the SQLAlchemy job store Fixes #438. --- apscheduler/jobstores/sqlalchemy.py | 4 ++-- docs/versionhistory.rst | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apscheduler/jobstores/sqlalchemy.py b/apscheduler/jobstores/sqlalchemy.py index fecbd83..dcfd3e5 100644 --- a/apscheduler/jobstores/sqlalchemy.py +++ b/apscheduler/jobstores/sqlalchemy.py @@ -11,7 +11,7 @@ except ImportError: # pragma: nocover try: from sqlalchemy import ( - create_engine, Table, Column, MetaData, Unicode, Float, LargeBinary, select) + create_engine, Table, Column, MetaData, Unicode, Float, LargeBinary, select, and_) from sqlalchemy.exc import IntegrityError from sqlalchemy.sql.expression import null except ImportError: # pragma: nocover @@ -134,7 +134,7 @@ class SQLAlchemyJobStore(BaseJobStore): jobs = [] selectable = select([self.jobs_t.c.id, self.jobs_t.c.job_state]).\ order_by(self.jobs_t.c.next_run_time) - selectable = selectable.where(*conditions) if conditions else selectable + selectable = selectable.where(and_(*conditions)) if conditions else selectable failed_job_ids = set() for row in self.engine.execute(selectable): try: diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index 4e6775a..b050e26 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -21,6 +21,8 @@ APScheduler, see the :doc:`migration section `. * Fixed memory leak when coroutine jobs raise exceptions (due to reference cycles in tracebacks) * Fixed inability to schedule wrapped functions with extra arguments when the wrapped function cannot accept them but the wrapper can (original PR by Egor Malykh) +* Fixed potential ``where`` clause error in the SQLAlchemy job store when a subclass uses more than + one search condition 3.6.3 -- cgit v1.2.1