Skip to content

Commit a5a0a44

Browse files
🐛 fix wrong project order_by of 'name' field (#5356)
1 parent 3eb91a9 commit a5a0a44

File tree

1 file changed

+6
-2
lines changed
  • services/web/server/src/simcore_service_webserver/projects

1 file changed

+6
-2
lines changed

services/web/server/src/simcore_service_webserver/projects/db.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ async def list_projects( # pylint: disable=too-many-arguments
325325
field="last_change_date", direction=OrderDirection.DESC
326326
),
327327
) -> tuple[list[dict[str, Any]], list[ProjectType], int]:
328+
assert (
329+
order_by.field in projects.columns
330+
), "Guaranteed by ProjectListWithJsonStrParams" # nosec
331+
328332
async with self.engine.acquire() as conn:
329333
user_groups: list[RowProxy] = await self._list_user_groups(conn, user_id)
330334

@@ -370,9 +374,9 @@ async def list_projects( # pylint: disable=too-many-arguments
370374
)
371375

372376
if order_by.direction == OrderDirection.ASC:
373-
query = query.order_by(sa.asc(order_by.field))
377+
query = query.order_by(sa.asc(getattr(projects.c, order_by.field)))
374378
else:
375-
query = query.order_by(sa.desc(order_by.field))
379+
query = query.order_by(sa.desc(getattr(projects.c, order_by.field)))
376380

377381
total_number_of_projects = await conn.scalar(
378382
query.with_only_columns(func.count()).order_by(None)

0 commit comments

Comments
 (0)