From 3547799079c0386b53945300aa688ae789e1fa9a Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 10 Jan 2025 00:35:52 +0100 Subject: [PATCH] Sort nulls at the end even in desc order --- api/src/controllers/movies.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/controllers/movies.ts b/api/src/controllers/movies.ts index 4f14221b..21683381 100644 --- a/api/src/controllers/movies.ts +++ b/api/src/controllers/movies.ts @@ -177,7 +177,7 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] }) .innerJoin(transQ, eq(shows.pk, transQ.pk)) .where(and(filter, keysetPaginate({ table: shows, after, sort }))) .orderBy( - ...sort.map((x) => (x.desc ? desc(shows[x.key]) : shows[x.key])), + ...sort.map((x) => (x.desc ? sql`${shows[x.key]} desc nulls last` : shows[x.key])), shows.pk, ) .limit(limit);