mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-14 00:04:34 -05:00
Feature/update to exposed v0.57.0 (#1150)
* Update to exposed-migrations v3.5.0 * Update to kotlin-logging v7.0.0 * Update to exposed v0.46.0 * Update to exposed v0.47.0 * Update to exposed v0.55.0 * Update to exposed v0.56.0 * Update to exposed v0.57.0
This commit is contained in:
@@ -9,7 +9,6 @@ import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.batchInsert
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.insertAndGetId
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
@@ -67,14 +66,15 @@ class CategoryMutation {
|
||||
transaction {
|
||||
val meta =
|
||||
CategoryMetaTable
|
||||
.select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
|
||||
.selectAll()
|
||||
.where { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
|
||||
.firstOrNull()
|
||||
|
||||
CategoryMetaTable.deleteWhere { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
|
||||
|
||||
val category =
|
||||
transaction {
|
||||
CategoryType(CategoryTable.select { CategoryTable.id eq categoryId }.first())
|
||||
CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq categoryId }.first())
|
||||
}
|
||||
|
||||
if (meta != null) {
|
||||
@@ -160,7 +160,7 @@ class CategoryMutation {
|
||||
|
||||
val category =
|
||||
transaction {
|
||||
CategoryType(CategoryTable.select { CategoryTable.id eq id }.first())
|
||||
CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq id }.first())
|
||||
}
|
||||
|
||||
UpdateCategoryPayload(
|
||||
@@ -177,7 +177,7 @@ class CategoryMutation {
|
||||
|
||||
val categories =
|
||||
transaction {
|
||||
CategoryTable.select { CategoryTable.id inList ids }.map { CategoryType(it) }
|
||||
CategoryTable.selectAll().where { CategoryTable.id inList ids }.map { CategoryType(it) }
|
||||
}
|
||||
|
||||
UpdateCategoriesPayload(
|
||||
@@ -207,7 +207,8 @@ class CategoryMutation {
|
||||
transaction {
|
||||
val currentOrder =
|
||||
CategoryTable
|
||||
.select { CategoryTable.id eq categoryId }
|
||||
.selectAll()
|
||||
.where { CategoryTable.id eq categoryId }
|
||||
.first()[CategoryTable.order]
|
||||
|
||||
if (currentOrder != position) {
|
||||
@@ -258,7 +259,7 @@ class CategoryMutation {
|
||||
asDataFetcherResult {
|
||||
val (clientMutationId, name, order, default, includeInUpdate, includeInDownload) = input
|
||||
transaction {
|
||||
require(CategoryTable.select { CategoryTable.name eq input.name }.isEmpty()) {
|
||||
require(CategoryTable.selectAll().where { CategoryTable.name eq input.name }.isEmpty()) {
|
||||
"'name' must be unique"
|
||||
}
|
||||
}
|
||||
@@ -296,7 +297,7 @@ class CategoryMutation {
|
||||
|
||||
Category.normalizeCategories()
|
||||
|
||||
CategoryType(CategoryTable.select { CategoryTable.id eq id }.first())
|
||||
CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq id }.first())
|
||||
}
|
||||
|
||||
CreateCategoryPayload(clientMutationId, category)
|
||||
@@ -328,14 +329,16 @@ class CategoryMutation {
|
||||
transaction {
|
||||
val category =
|
||||
CategoryTable
|
||||
.select { CategoryTable.id eq categoryId }
|
||||
.selectAll()
|
||||
.where { CategoryTable.id eq categoryId }
|
||||
.firstOrNull()
|
||||
|
||||
val mangas =
|
||||
transaction {
|
||||
MangaTable
|
||||
.innerJoin(CategoryMangaTable)
|
||||
.select { CategoryMangaTable.category eq categoryId }
|
||||
.selectAll()
|
||||
.where { CategoryMangaTable.category eq categoryId }
|
||||
.map { MangaType(it) }
|
||||
}
|
||||
|
||||
@@ -401,7 +404,8 @@ class CategoryMutation {
|
||||
patch.addToCategories.forEach { categoryId ->
|
||||
val existingMapping =
|
||||
CategoryMangaTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
(CategoryMangaTable.manga eq mangaId) and (CategoryMangaTable.category eq categoryId)
|
||||
}.isNotEmpty()
|
||||
|
||||
@@ -428,7 +432,7 @@ class CategoryMutation {
|
||||
|
||||
val manga =
|
||||
transaction {
|
||||
MangaType(MangaTable.select { MangaTable.id eq id }.first())
|
||||
MangaType(MangaTable.selectAll().where { MangaTable.id eq id }.first())
|
||||
}
|
||||
|
||||
UpdateMangaCategoriesPayload(
|
||||
@@ -445,7 +449,7 @@ class CategoryMutation {
|
||||
|
||||
val mangas =
|
||||
transaction {
|
||||
MangaTable.select { MangaTable.id inList ids }.map { MangaType(it) }
|
||||
MangaTable.selectAll().where { MangaTable.id inList ids }.map { MangaType(it) }
|
||||
}
|
||||
|
||||
UpdateMangasCategoriesPayload(
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.statements.BatchUpdateStatement
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.asDataFetcherResult
|
||||
@@ -65,8 +65,8 @@ class ChapterMutation {
|
||||
val chapterIdToPageCount =
|
||||
if (patch.lastPageRead != null) {
|
||||
ChapterTable
|
||||
.slice(ChapterTable.id, ChapterTable.pageCount)
|
||||
.select { ChapterTable.id inList ids }
|
||||
.select(ChapterTable.id, ChapterTable.pageCount)
|
||||
.where { ChapterTable.id inList ids }
|
||||
.groupBy { it[ChapterTable.id].value }
|
||||
.mapValues { it.value.firstOrNull()?.let { it[ChapterTable.pageCount] } }
|
||||
} else {
|
||||
@@ -103,7 +103,7 @@ class ChapterMutation {
|
||||
|
||||
val chapter =
|
||||
transaction {
|
||||
ChapterType(ChapterTable.select { ChapterTable.id eq id }.first())
|
||||
ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq id }.first())
|
||||
}
|
||||
|
||||
UpdateChapterPayload(
|
||||
@@ -120,7 +120,7 @@ class ChapterMutation {
|
||||
|
||||
val chapters =
|
||||
transaction {
|
||||
ChapterTable.select { ChapterTable.id inList ids }.map { ChapterType(it) }
|
||||
ChapterTable.selectAll().where { ChapterTable.id inList ids }.map { ChapterType(it) }
|
||||
}
|
||||
|
||||
UpdateChaptersPayload(
|
||||
@@ -149,7 +149,8 @@ class ChapterMutation {
|
||||
val chapters =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { ChapterTable.manga eq mangaId }
|
||||
.selectAll()
|
||||
.where { ChapterTable.manga eq mangaId }
|
||||
.orderBy(ChapterTable.sourceOrder)
|
||||
.map { ChapterType(it) }
|
||||
}
|
||||
@@ -201,14 +202,15 @@ class ChapterMutation {
|
||||
transaction {
|
||||
val meta =
|
||||
ChapterMetaTable
|
||||
.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
|
||||
.selectAll()
|
||||
.where { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
|
||||
.firstOrNull()
|
||||
|
||||
ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
|
||||
|
||||
val chapter =
|
||||
transaction {
|
||||
ChapterType(ChapterTable.select { ChapterTable.id eq chapterId }.first())
|
||||
ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first())
|
||||
}
|
||||
|
||||
if (meta != null) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
|
||||
import graphql.execution.DataFetcherResult
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.asDataFetcherResult
|
||||
import suwayomi.tachidesk.graphql.types.ChapterType
|
||||
@@ -39,7 +39,8 @@ class DownloadMutation {
|
||||
chapters =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { ChapterTable.id inList chapters }
|
||||
.selectAll()
|
||||
.where { ChapterTable.id inList chapters }
|
||||
.map { ChapterType(it) }
|
||||
},
|
||||
)
|
||||
@@ -66,7 +67,7 @@ class DownloadMutation {
|
||||
clientMutationId = clientMutationId,
|
||||
chapters =
|
||||
transaction {
|
||||
ChapterType(ChapterTable.select { ChapterTable.id eq chapter }.first())
|
||||
ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq chapter }.first())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
|
||||
import eu.kanade.tachiyomi.source.local.LocalSource
|
||||
import graphql.execution.DataFetcherResult
|
||||
import io.javalin.http.UploadedFile
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.asDataFetcherResult
|
||||
import suwayomi.tachidesk.graphql.types.ExtensionType
|
||||
@@ -49,7 +49,8 @@ class ExtensionMutation {
|
||||
val extensions =
|
||||
transaction {
|
||||
ExtensionTable
|
||||
.select { ExtensionTable.pkgName inList ids }
|
||||
.selectAll()
|
||||
.where { ExtensionTable.pkgName inList ids }
|
||||
.map { ExtensionType(it) }
|
||||
}
|
||||
|
||||
@@ -82,7 +83,8 @@ class ExtensionMutation {
|
||||
val extension =
|
||||
transaction {
|
||||
ExtensionTable
|
||||
.select { ExtensionTable.pkgName eq id }
|
||||
.selectAll()
|
||||
.where { ExtensionTable.pkgName eq id }
|
||||
.firstOrNull()
|
||||
?.let { ExtensionType(it) }
|
||||
}
|
||||
@@ -105,7 +107,8 @@ class ExtensionMutation {
|
||||
val extensions =
|
||||
transaction {
|
||||
ExtensionTable
|
||||
.select { ExtensionTable.pkgName inList ids }
|
||||
.selectAll()
|
||||
.where { ExtensionTable.pkgName inList ids }
|
||||
.map { ExtensionType(it) }
|
||||
}
|
||||
|
||||
@@ -136,7 +139,8 @@ class ExtensionMutation {
|
||||
val extensions =
|
||||
transaction {
|
||||
ExtensionTable
|
||||
.select { ExtensionTable.name neq LocalSource.EXTENSION_NAME }
|
||||
.selectAll()
|
||||
.where { ExtensionTable.name neq LocalSource.EXTENSION_NAME }
|
||||
.map { ExtensionType(it) }
|
||||
}
|
||||
|
||||
@@ -167,7 +171,8 @@ class ExtensionMutation {
|
||||
asDataFetcherResult {
|
||||
Extension.installExternalExtension(extensionFile.content(), extensionFile.filename())
|
||||
|
||||
val dbExtension = transaction { ExtensionTable.select { ExtensionTable.apkName eq extensionFile.filename() }.first() }
|
||||
val dbExtension =
|
||||
transaction { ExtensionTable.selectAll().where { ExtensionTable.apkName eq extensionFile.filename() }.first() }
|
||||
|
||||
InstallExternalExtensionPayload(
|
||||
clientMutationId,
|
||||
|
||||
@@ -4,7 +4,7 @@ import graphql.execution.DataFetcherResult
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.graphql.asDataFetcherResult
|
||||
@@ -75,7 +75,8 @@ class MangaMutation {
|
||||
val mangas =
|
||||
transaction {
|
||||
MangaTable
|
||||
.select { (MangaTable.id inList ids) and (MangaTable.initialized eq false) }
|
||||
.selectAll()
|
||||
.where { (MangaTable.id inList ids) and (MangaTable.initialized eq false) }
|
||||
.map { MangaTable.toDataClass(it) }
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ class MangaMutation {
|
||||
|
||||
val manga =
|
||||
transaction {
|
||||
MangaType(MangaTable.select { MangaTable.id eq id }.first())
|
||||
MangaType(MangaTable.selectAll().where { MangaTable.id eq id }.first())
|
||||
}
|
||||
|
||||
UpdateMangaPayload(
|
||||
@@ -118,7 +119,7 @@ class MangaMutation {
|
||||
|
||||
val mangas =
|
||||
transaction {
|
||||
MangaTable.select { MangaTable.id inList ids }.map { MangaType(it) }
|
||||
MangaTable.selectAll().where { MangaTable.id inList ids }.map { MangaType(it) }
|
||||
}
|
||||
|
||||
UpdateMangasPayload(
|
||||
@@ -148,7 +149,7 @@ class MangaMutation {
|
||||
|
||||
val manga =
|
||||
transaction {
|
||||
MangaTable.select { MangaTable.id eq id }.first()
|
||||
MangaTable.selectAll().where { MangaTable.id eq id }.first()
|
||||
}
|
||||
FetchMangaPayload(
|
||||
clientMutationId = clientMutationId,
|
||||
@@ -198,14 +199,15 @@ class MangaMutation {
|
||||
transaction {
|
||||
val meta =
|
||||
MangaMetaTable
|
||||
.select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
|
||||
.selectAll()
|
||||
.where { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
|
||||
.firstOrNull()
|
||||
|
||||
MangaMetaTable.deleteWhere { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
|
||||
|
||||
val manga =
|
||||
transaction {
|
||||
MangaType(MangaTable.select { MangaTable.id eq mangaId }.first())
|
||||
MangaType(MangaTable.selectAll().where { MangaTable.id eq mangaId }.first())
|
||||
}
|
||||
|
||||
if (meta != null) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
|
||||
import graphql.execution.DataFetcherResult
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.global.impl.GlobalMeta
|
||||
import suwayomi.tachidesk.global.model.table.GlobalMetaTable
|
||||
@@ -49,7 +49,8 @@ class MetaMutation {
|
||||
transaction {
|
||||
val meta =
|
||||
GlobalMetaTable
|
||||
.select { GlobalMetaTable.key eq key }
|
||||
.selectAll()
|
||||
.where { GlobalMetaTable.key eq key }
|
||||
.firstOrNull()
|
||||
|
||||
GlobalMetaTable.deleteWhere { GlobalMetaTable.key eq key }
|
||||
|
||||
@@ -9,7 +9,7 @@ import graphql.execution.DataFetcherResult
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.asDataFetcherResult
|
||||
import suwayomi.tachidesk.graphql.types.FilterChange
|
||||
@@ -69,7 +69,8 @@ class SourceMutation {
|
||||
transaction {
|
||||
val meta =
|
||||
SourceMetaTable
|
||||
.select { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) }
|
||||
.selectAll()
|
||||
.where { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) }
|
||||
.firstOrNull()
|
||||
|
||||
SourceMetaTable.deleteWhere { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) }
|
||||
@@ -77,7 +78,8 @@ class SourceMutation {
|
||||
val source =
|
||||
transaction {
|
||||
SourceTable
|
||||
.select { SourceTable.id eq sourceId }
|
||||
.selectAll()
|
||||
.where { SourceTable.id eq sourceId }
|
||||
.firstOrNull()
|
||||
?.let { SourceType(it) }
|
||||
}
|
||||
@@ -143,7 +145,8 @@ class SourceMutation {
|
||||
val mangas =
|
||||
transaction {
|
||||
MangaTable
|
||||
.select { MangaTable.id inList mangaIds }
|
||||
.selectAll()
|
||||
.where { MangaTable.id inList mangaIds }
|
||||
.map { MangaType(it) }
|
||||
}.sortedBy {
|
||||
mangaIds.indexOf(it.id)
|
||||
@@ -199,7 +202,7 @@ class SourceMutation {
|
||||
preferences = Source.getSourcePreferencesRaw(sourceId).map { preferenceOf(it) },
|
||||
source =
|
||||
transaction {
|
||||
SourceType(SourceTable.select { SourceTable.id eq sourceId }.first())!!
|
||||
SourceType(SourceTable.selectAll().where { SourceTable.id eq sourceId }.first())!!
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated
|
||||
import com.expediagroup.graphql.generator.annotations.GraphQLDescription
|
||||
import graphql.execution.DataFetcherResult
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.asDataFetcherResult
|
||||
import suwayomi.tachidesk.graphql.types.TrackRecordType
|
||||
@@ -127,7 +127,8 @@ class TrackMutation {
|
||||
val trackRecord =
|
||||
transaction {
|
||||
TrackRecordTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
TrackRecordTable.mangaId eq mangaId and (TrackRecordTable.trackerId eq trackerId)
|
||||
}.first()
|
||||
}
|
||||
@@ -156,7 +157,8 @@ class TrackMutation {
|
||||
val trackRecord =
|
||||
transaction {
|
||||
TrackRecordTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
TrackRecordTable.id eq recordId
|
||||
}.first()
|
||||
}
|
||||
@@ -187,7 +189,8 @@ class TrackMutation {
|
||||
val trackRecord =
|
||||
transaction {
|
||||
TrackRecordTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
TrackRecordTable.id eq recordId
|
||||
}.firstOrNull()
|
||||
}
|
||||
@@ -217,7 +220,8 @@ class TrackMutation {
|
||||
val trackRecords =
|
||||
transaction {
|
||||
TrackRecordTable
|
||||
.select { TrackRecordTable.mangaId eq mangaId }
|
||||
.selectAll()
|
||||
.where { TrackRecordTable.mangaId eq mangaId }
|
||||
.toList()
|
||||
}
|
||||
TrackProgressPayload(
|
||||
@@ -262,7 +266,8 @@ class TrackMutation {
|
||||
val trackRecord =
|
||||
transaction {
|
||||
TrackRecordTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
TrackRecordTable.id eq input.recordId
|
||||
}.firstOrNull()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
|
||||
import graphql.execution.DataFetcherResult
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.asDataFetcherResult
|
||||
import suwayomi.tachidesk.graphql.types.UpdateStatus
|
||||
@@ -61,7 +61,7 @@ class UpdateMutation {
|
||||
fun updateCategoryManga(input: UpdateCategoryMangaInput): CompletableFuture<DataFetcherResult<UpdateCategoryMangaPayload?>> {
|
||||
val categories =
|
||||
transaction {
|
||||
CategoryTable.select { CategoryTable.id inList input.categories }.map {
|
||||
CategoryTable.selectAll().where { CategoryTable.id inList input.categories }.map {
|
||||
CategoryTable.toDataClass(it)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user