Skip to content

Commit

Permalink
Fix SA2.0 usage in model.PSAAssociation
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Oct 2, 2023
1 parent b109645 commit 6c06a9e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
Column,
column,
DateTime,
delete,
desc,
event,
false,
Expand Down Expand Up @@ -9273,7 +9274,8 @@ def save(self):
@classmethod
def store(cls, server_url, association):
try:
assoc = cls.sa_session.query(cls).filter_by(server_url=server_url, handle=association.handle)[0]
stmt = select(PSAAssociation).filter_by(server_url=server_url, handle=association.handle).limit(1)
assoc = cls.sa_session.scalars(stmt).first()
except IndexError:
assoc = cls(server_url=server_url, handle=association.handle)
assoc.secret = base64.encodebytes(association.secret).decode()
Expand All @@ -9286,11 +9288,17 @@ def store(cls, server_url, association):

@classmethod
def get(cls, *args, **kwargs):
return cls.sa_session.query(cls).filter_by(*args, **kwargs)
stmt = select(PSAAssociation).filter_by(*args, **kwargs)
return cls.sa_session.scalars(stmt)

@classmethod
def remove(cls, ids_to_delete):
cls.sa_session.query(cls).filter(cls.id.in_(ids_to_delete)).delete(synchronize_session="fetch")
stmt = (
delete(PSAAssociation)
.where(PSAAssociation.id.in_(ids_to_delete))
.execution_options(synchronize_session="fetch")
)
PSAAssociation.sa_session.execute(stmt)


class PSACode(Base, CodeMixin, RepresentById):
Expand Down

0 comments on commit 6c06a9e

Please sign in to comment.