From 4972447926f6384b34cb395deed744d6d1332a42 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 1 Nov 2023 12:54:41 +0100 Subject: [PATCH] Only batch update in case list is not empty Apparently "BatchUpdateStatement" can't handle an empty data set --- .../suwayomi/tachidesk/manga/impl/Chapter.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt index ffc5cbc4ec..8a19d84330 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt @@ -175,18 +175,20 @@ object Chapter { } } - BatchUpdateStatement(ChapterTable).apply { - chaptersToUpdate.forEach { - addBatch(EntityID(it.id, ChapterTable)) - this[ChapterTable.name] = it.name - this[ChapterTable.date_upload] = it.uploadDate - this[ChapterTable.chapter_number] = it.chapterNumber - this[ChapterTable.scanlator] = it.scanlator - this[ChapterTable.sourceOrder] = it.index - this[ChapterTable.fetchedAt] = it.fetchedAt - this[ChapterTable.realUrl] = it.realUrl + if (chaptersToUpdate.isNotEmpty()) { + BatchUpdateStatement(ChapterTable).apply { + chaptersToUpdate.forEach { + addBatch(EntityID(it.id, ChapterTable)) + this[ChapterTable.name] = it.name + this[ChapterTable.date_upload] = it.uploadDate + this[ChapterTable.chapter_number] = it.chapterNumber + this[ChapterTable.scanlator] = it.scanlator + this[ChapterTable.sourceOrder] = it.index + this[ChapterTable.fetchedAt] = it.fetchedAt + this[ChapterTable.realUrl] = it.realUrl + } + execute(this@transaction) } - execute(this@transaction) } MangaTable.update({ MangaTable.id eq mangaId }) {