Fix mangas query with active sorting and postgresql db (#2042)

fixes #2036
This commit is contained in:
schroda
2026-05-17 01:41:37 +02:00
committed by GitHub
parent 558407d92c
commit fbb383b1f1
2 changed files with 10 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- (**Extension**) Do not indicate an update is available when the extension is not installed
- (**Chapter**) Fix losing chapter data on failed chapter list update
- (**Chapter**) Fix database error when fetching chapter updates
- (**Manga/API**) Fix "mangas" graphql query with active sorting and using a postgresql database (QUERY "mangas")
## [v2.2.2100] + [WebUI: v20260508.01] - 2026-05-08

View File

@@ -247,11 +247,18 @@ class MangaQuery {
MangaTable
.leftJoin(CategoryMangaTable)
.select(MangaTable.columns)
.withDistinctOn(MangaTable.id)
val applySorting = order != null || orderBy != null || (last != null || before != null)
if (applySorting) {
res.withDistinctOn(MangaTable.id to SortOrder.ASC)
} else {
res.withDistinctOn(MangaTable.id)
}
res.applyOps(condition, filter)
if (order != null || orderBy != null || (last != null || before != null)) {
if (applySorting) {
val baseSort = listOf(MangaOrder(MangaOrderBy.ID, SortOrder.ASC))
val deprecatedSort = listOfNotNull(orderBy?.let { MangaOrder(orderBy, orderByType) })
val actualSort = (order.orEmpty() + deprecatedSort + baseSort)