Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.2] Fix bug: create new PSAAssociation if not in database #17516

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading