From 29ba66be5f1e97aae26d5a98baa86ecc6409866b Mon Sep 17 00:00:00 2001 From: John Davis Date: Mon, 2 Oct 2023 17:41:37 -0400 Subject: [PATCH] Fix bug (missing commit) + SA2.0 usage in model.Job.update_hdca_update_time_for_job --- lib/galaxy/model/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 04d4552ae620..cc5ca1c46b6f 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1860,26 +1860,29 @@ def to_dict(self, view="collection", system_details=False): def update_hdca_update_time_for_job(self, update_time, sa_session, supports_skip_locked): subq = ( - sa_session.query(HistoryDatasetCollectionAssociation.id) + select(HistoryDatasetCollectionAssociation.id) .join(ImplicitCollectionJobs) .join(ImplicitCollectionJobsJobAssociation) .filter(ImplicitCollectionJobsJobAssociation.job_id == self.id) ) if supports_skip_locked: - subq = subq.with_for_update(skip_locked=True).subquery() + subq = subq.with_for_update(skip_locked=True) + subq = subq.subquery() implicit_statement = ( - HistoryDatasetCollectionAssociation.table.update() - .where(HistoryDatasetCollectionAssociation.table.c.id.in_(select(subq))) + update(HistoryDatasetCollectionAssociation) + .where(HistoryDatasetCollectionAssociation.id.in_(subq)) .values(update_time=update_time) ) explicit_statement = ( - HistoryDatasetCollectionAssociation.table.update() - .where(HistoryDatasetCollectionAssociation.table.c.job_id == self.id) + update(HistoryDatasetCollectionAssociation) + .where(HistoryDatasetCollectionAssociation.job_id == self.id) .values(update_time=update_time) ) sa_session.execute(explicit_statement) if supports_skip_locked: sa_session.execute(implicit_statement) + with transaction(sa_session): + sa_session.commit() else: conn = sa_session.connection(execution_options={"isolation_level": "SERIALIZABLE"}) with conn.begin() as trans: