Skip to content

Commit

Permalink
Merge pull request #17516 from jdavcs/23.2_bug_17508
Browse files Browse the repository at this point in the history
[23.2] Fix bug: create new PSAAssociation if not in database
  • Loading branch information
nsoranzo authored Feb 22, 2024
2 parents f0fbe77 + fe93fd8 commit 036e469
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9526,11 +9526,12 @@ def save(self):

@classmethod
def store(cls, server_url, association):
try:
def get_or_create():
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)
return assoc or cls(server_url=server_url, handle=association.handle)

assoc = get_or_create()
assoc.secret = base64.encodebytes(association.secret).decode()
assoc.issued = association.issued
assoc.lifetime = association.lifetime
Expand All @@ -9542,7 +9543,7 @@ def store(cls, server_url, association):
@classmethod
def get(cls, *args, **kwargs):
stmt = select(PSAAssociation).filter_by(*args, **kwargs)
return cls.sa_session.scalars(stmt)
return cls.sa_session.scalars(stmt).all()

@classmethod
def remove(cls, ids_to_delete):
Expand Down

0 comments on commit 036e469

Please sign in to comment.