Skip to content

Commit

Permalink
Fix SA 2.0 ORM usage in model.tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Sep 28, 2023
1 parent fb01a41 commit 85e6fe4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/galaxy/model/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ def get_tags_str(self, tags):

def get_tag_by_id(self, tag_id):
"""Get a Tag object from a tag id."""
return self.sa_session.query(galaxy.model.Tag).filter_by(id=tag_id).first()
return self.sa_session.get(galaxy.model.Tag, tag_id)

def get_tag_by_name(self, tag_name):
"""Get a Tag object from a tag name (string)."""
if tag_name:
return self.sa_session.query(galaxy.model.Tag).filter_by(name=tag_name.lower()).first()
return self.sa_session.scalars(select(galaxy.model.Tag).filter_by(name=tag_name.lower()).limit(1)).first()
return None

def _create_tag(self, tag_str: str):
Expand All @@ -317,7 +317,7 @@ def _create_tag(self, tag_str: str):
return tag

def _get_tag(self, tag_name):
return self.sa_session.query(galaxy.model.Tag).filter_by(name=tag_name).first()
return self.sa_session.scalars(select(galaxy.model.Tag).filter_by(name=tag_name).limit(1)).first()

def _create_tag_instance(self, tag_name):
# For good performance caller should first check if there's already an appropriate tag
Expand Down

0 comments on commit 85e6fe4

Please sign in to comment.