From 9c8d18fc2cdc3f3e302a934371cb788d668f048e Mon Sep 17 00:00:00 2001 From: John Davis Date: Thu, 19 Oct 2023 10:39:25 -0400 Subject: [PATCH] Fix bug in SA statement: desc() applied to column, not statement --- lib/tool_shed/util/repository_util.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tool_shed/util/repository_util.py b/lib/tool_shed/util/repository_util.py index 1cc1449bc40b..0828e1652247 100644 --- a/lib/tool_shed/util/repository_util.py +++ b/lib/tool_shed/util/repository_util.py @@ -565,12 +565,15 @@ def get_repositories( if installable: stmt1 = select(RepositoryMetadata.repository_id) stmt = stmt.where(Repository.id.in_(stmt1)) + if sort_key == "owner": - stmt = stmt.order_by(User.username) + sort_by = User.username else: - stmt = stmt.order_by(Repository.name) + sort_by = Repository.name if sort_order == "desc": - stmt = stmt.desc() + sort_by = sort_by.desc() + stmt = stmt.order_by(sort_by) + if page is not None: page = int(page) stmt = stmt.limit(per_page)