Skip to content

Commit

Permalink
Fix select(foo=bar, baz=bam) SA20 warnings
Browse files Browse the repository at this point in the history
- func.count() does not need "*" argument
- select_from is not needed if it can be derived from the columns
  • Loading branch information
jdavcs committed Jun 21, 2023
1 parent 98413d3 commit c713508
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/galaxy/model/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,18 @@ def get_community_tags(self, item=None, limit=None):
if not item_tag_assoc_class:
return []
# Build select statement.
cols_to_select = [item_tag_assoc_class.table.c.tag_id, func.count("*")]
from_obj = item_tag_assoc_class.table.join(item_class.table).join(galaxy.model.Tag.table)
where_clause = self.get_id_col_in_item_tag_assoc_table(item_class) == item.id
order_by = [func.count("*").desc()]
order_by = [func.count().desc()]
group_by = item_tag_assoc_class.table.c.tag_id
# Do query and get result set.
query = select(
columns=cols_to_select,
from_obj=from_obj,
whereclause=where_clause,
group_by=group_by,
order_by=order_by,
limit=limit,
query = (
select(item_tag_assoc_class.table.c.tag_id, func.count())
.select_from(from_obj)
.where(where_clause)
.group_by(group_by)
.order_by(order_by)
.limit(limit)
)
result_set = self.sa_session.execute(query)
# Return community tags.
Expand All @@ -118,9 +117,7 @@ def get_community_tags(self, item=None, limit=None):
return community_tags

def get_tool_tags(self):
query = select(
columns=[galaxy.model.ToolTagAssociation.table.c.tag_id], from_obj=galaxy.model.ToolTagAssociation.table
).distinct()
query = select(galaxy.model.ToolTagAssociation.table.c.tag_id).distinct()
result_set = self.sa_session.execute(query)

tags = []
Expand Down

0 comments on commit c713508

Please sign in to comment.