Skip to content

Commit

Permalink
Fix SA2.0 syntax in test_workflow_refactoring
Browse files Browse the repository at this point in the history
.unique() is required due to joint eager loading specified in the
StoredWorkflow model.
  • Loading branch information
jdavcs committed Jul 21, 2023
1 parent f2c751b commit b7d571c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/integration/test_workflow_refactoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
List,
)

from sqlalchemy import select

from galaxy.managers.context import ProvidesAppContext
from galaxy.managers.workflows import RefactorRequest
from galaxy.model import (
Expand Down Expand Up @@ -767,7 +769,8 @@ def _export_for_update(self, workflow):
yield workflow_object

def _refactor(self, actions: List[Dict[str, Any]], stored_workflow=None, dry_run=False, style="ga"):
user = self._app.model.session.query(User).order_by(User.id.desc()).limit(1).one()
stmt = select(User).order_by(User.id.desc()).limit(1)
user = self._app.model.session.execute(stmt).scalar_one()
mock_trans = MockTrans(self._app, user)

app = self._app
Expand Down Expand Up @@ -818,11 +821,13 @@ def _dry_run(self, actions: ActionsJson, stored_workflow=None):
return response

def _model_last_time(self, clazz):
obj = self._app.model.session.query(clazz).order_by(clazz.update_time.desc()).limit(1).one()
stmt = select(clazz).order_by(clazz.update_time.desc()).limit(1)
obj = self._app.model.session.execute(stmt).unique().scalar_one()
return obj.update_time

def _model_last_id(self, clazz):
obj = self._app.model.session.query(clazz).order_by(clazz.id.desc()).limit(1).one_or_none()
stmt = select(clazz).order_by(clazz.id.desc()).limit(1)
obj = self._app.model.session.execute(stmt).scalar_one_or_none()
return obj.id if obj else None

@property
Expand All @@ -835,7 +840,8 @@ def _most_recent_stored_workflow(self):

def _recent_stored_workflow(self, n=1):
app = self._app
return app.model.session.query(StoredWorkflow).order_by(StoredWorkflow.id.desc()).limit(n).all()[-1]
stmt = select(StoredWorkflow).order_by(StoredWorkflow.id.desc()).limit(n)
return app.model.session.scalars(stmt).unique().all()[-1]

@property
def _latest_workflow(self):
Expand Down

0 comments on commit b7d571c

Please sign in to comment.