From 48d3d454c00effa56c031d53a5f132338b5dce7b Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Wed, 14 Sep 2022 21:36:23 +0600 Subject: [PATCH] Fix missing condition on `getLibrary` sql query (#8006) --- app/src/main/sqldelight/data/mangas.sq | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/sqldelight/data/mangas.sq b/app/src/main/sqldelight/data/mangas.sq index debb772273..41a5931338 100644 --- a/app/src/main/sqldelight/data/mangas.sq +++ b/app/src/main/sqldelight/data/mangas.sq @@ -75,21 +75,22 @@ GROUP BY source; getLibrary: SELECT M.*, COALESCE(MC.category_id, 0) AS category FROM ( - SELECT mangas.*, COALESCE(C.unreadCount, 0) AS unread_count, COALESCE(R.readCount, 0) AS read_count + SELECT mangas.*, COALESCE(UR.unreadCount, 0) AS unread_count, COALESCE(R.readCount, 0) AS read_count FROM mangas LEFT JOIN ( SELECT chapters.manga_id, COUNT(*) AS unreadCount FROM chapters WHERE chapters.read = 0 GROUP BY chapters.manga_id - ) AS C - ON mangas._id = C.manga_id + ) AS UR + ON mangas._id = UR.manga_id LEFT JOIN ( SELECT chapters.manga_id, COUNT(*) AS readCount FROM chapters WHERE chapters.read = 1 GROUP BY chapters.manga_id ) AS R + ON mangas._id = R.manga_id WHERE mangas.favorite = 1 GROUP BY mangas._id ORDER BY mangas.title