Skip to content

Commit

Permalink
Fix bug: create new object if not in db
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Feb 20, 2024
1 parent ea9e2fb commit 3c6fb7e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 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 Down

0 comments on commit 3c6fb7e

Please sign in to comment.