fix(sql): Union issue

It doesn't like history.*
This commit is contained in:
Ahmad Ansori Palembani 2024-08-27 09:50:32 +07:00
parent 3199f07363
commit 6e3eaad481
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 24 additions and 16 deletions

View file

@ -84,7 +84,7 @@ data class MangaChapterHistory(val manga: Manga, val chapter: Chapter, val histo
mangaId = _mangaId!!,
url = chapterUrl!!,
name = name!!,
scanlator = scanlator!!,
scanlator = scanlator,
read = read!!,
bookmark = bookmark!!,
lastPageRead = lastPageRead!!,
@ -98,11 +98,12 @@ data class MangaChapterHistory(val manga: Manga, val chapter: Chapter, val histo
historyId?.let {
History.mapper(
id = historyId,
chapterId = historyChapterId!!,
chapterId = historyChapterId ?: chapterId ?: 0L,
lastRead = historyLastRead,
timeRead = historyTimeRead,
)
} ?: History.create().apply {
(historyChapterId ?: chapterId)?.let { chapter_id = it }
historyLastRead?.let { last_read = it }
historyTimeRead?.let { time_read = it }
},

View file

@ -67,7 +67,10 @@ SELECT * FROM (
SELECT
mangas.*,
chapters.*,
history.*
history.history_id AS history_id,
history.history_chapter_id AS history_chapter_id,
history.history_last_read AS history_last_read,
history.history_time_read AS history_time_read
FROM (
SELECT mangas.*
FROM mangas
@ -166,24 +169,28 @@ UNION --
SELECT * FROM (
SELECT
mangas.*,
NULL AS _id,
NULL AS manga_id,
NULL AS url,
NULL AS name,
NULL AS read,
NULL AS scanlator,
NULL AS bookmark,
NULL AS date_fetch,
NULL AS date_upload,
NULL AS last_page_read,
NULL AS pages_left,
NULL AS chapter_number,
NULL AS source_order,
chapters.*,
NULL AS history_id,
NULL AS history_chapter_id,
mangas.date_added AS history_last_read,
NULL AS history_time_read
FROM mangas
JOIN (
SELECT
NULL AS _id,
NULL AS manga_id,
NULL AS url,
NULL AS name,
NULL AS read,
NULL AS scanlator,
NULL AS bookmark,
NULL AS date_fetch,
NULL AS date_upload,
NULL AS last_page_read,
NULL AS pages_left,
NULL AS chapter_number,
NULL AS source_order
) AS chapters
WHERE favorite = 1
AND lower(title) LIKE '%' || :search || '%'
)