Skip to content

Commit

Permalink
Update to exposed v0.56.0
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda committed Nov 27, 2024
1 parent ab93fd3 commit ecb7982
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 62 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ serialization = "1.7.3"
okhttp = "5.0.0-alpha.14" # Major version is locked by Tachiyomi extensions
javalin = "6.3.0"
jackson = "2.18.1" # jackson version locked by javalin, ref: `io.javalin.core.util.OptionalDependency`
exposed = "0.55.0"
exposed = "0.56.0"
dex2jar = "v64" # Stuck until https://github.com/ThexXTURBOXx/dex2jar/issues/27 is fixed
polyglot = "24.1.1"
settings = "1.2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CategoryQuery {
): CompletableFuture<CategoryType> = dataFetchingEnvironment.getValueFromDataLoader("CategoryDataLoader", id)

enum class CategoryOrderBy(
override val column: Column<out Comparable<*>>,
override val column: Column<*>,
) : OrderBy<CategoryType> {
ID(CategoryTable.id),
NAME(CategoryTable.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ChapterQuery {
): CompletableFuture<ChapterType> = dataFetchingEnvironment.getValueFromDataLoader("ChapterDataLoader", id)

enum class ChapterOrderBy(
override val column: Column<out Comparable<*>>,
override val column: Column<*>,
) : OrderBy<ChapterType> {
ID(ChapterTable.id),
SOURCE_ORDER(ChapterTable.sourceOrder),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ExtensionQuery {
): CompletableFuture<ExtensionType> = dataFetchingEnvironment.getValueFromDataLoader("ExtensionDataLoader", pkgName)

enum class ExtensionOrderBy(
override val column: Column<out Comparable<*>>,
override val column: Column<*>,
) : OrderBy<ExtensionType> {
PKG_NAME(ExtensionTable.pkgName),
NAME(ExtensionTable.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompare
import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompareEntity
import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompareString
import suwayomi.tachidesk.graphql.queries.filter.applyOps
import suwayomi.tachidesk.graphql.queries.util.distinctOn
import suwayomi.tachidesk.graphql.server.primitives.Cursor
import suwayomi.tachidesk.graphql.server.primitives.Order
import suwayomi.tachidesk.graphql.server.primitives.OrderBy
Expand All @@ -52,7 +51,7 @@ class MangaQuery {
): CompletableFuture<MangaType> = dataFetchingEnvironment.getValueFromDataLoader("MangaDataLoader", id)

enum class MangaOrderBy(
override val column: Column<out Comparable<*>>,
override val column: Column<*>,
) : OrderBy<MangaType> {
ID(MangaTable.id),
TITLE(MangaTable.title),
Expand Down Expand Up @@ -241,11 +240,8 @@ class MangaQuery {
val res =
MangaTable
.leftJoin(CategoryMangaTable)
.select(
distinctOn(MangaTable.id),
*(MangaTable.columns).toTypedArray(),
*(CategoryMangaTable.columns).toTypedArray(),
)
.select(MangaTable.columns)
.withDistinctOn(MangaTable.id)

res.applyOps(condition, filter)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MetaQuery {
): CompletableFuture<GlobalMetaType> = dataFetchingEnvironment.getValueFromDataLoader("GlobalMetaDataLoader", key)

enum class MetaOrderBy(
override val column: Column<out Comparable<*>>,
override val column: Column<*>,
) : OrderBy<GlobalMetaType> {
KEY(GlobalMetaTable.key),
VALUE(GlobalMetaTable.value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SourceQuery {
): CompletableFuture<SourceType> = dataFetchingEnvironment.getValueFromDataLoader("SourceDataLoader", id)

enum class SourceOrderBy(
override val column: Column<out Comparable<*>>,
override val column: Column<*>,
) : OrderBy<SourceType> {
ID(SourceTable.id),
NAME(SourceTable.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class TrackQuery {
dataFetchingEnvironment.getValueFromDataLoader<Int, TrackRecordType>("TrackRecordDataLoader", id)

enum class TrackRecordOrderBy(
override val column: Column<out Comparable<*>>,
override val column: Column<*>,
) : OrderBy<TrackRecordType> {
ID(TrackRecordTable.id),
MANGA_ID(TrackRecordTable.mangaId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,47 +539,59 @@ class OpAnd(
) = andWhere(value) { column eq it }
}

@Suppress("UNCHECKED_CAST")
fun <T : Comparable<T>, S : T?> andFilterWithCompare(
column: Column<S>,
filter: ComparableScalarFilter<T>?,
): Op<Boolean>? {
filter ?: return null
val opAnd = OpAnd(andFilter(column, filter))
val opAnd = OpAnd()

opAnd.andWhere(filter.lessThan) { column less it }
opAnd.andWhere(filter.lessThanOrEqualTo) { column lessEq it }
opAnd.andWhere(filter.greaterThan) { column greater it }
opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it }

opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() }

opAnd.andWhere(filter.equalTo) { column eq it as S }
opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it as S }
opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it as S) }
opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it as S) }
if (!filter.`in`.isNullOrEmpty()) {
opAnd.andWhere(filter.`in`) { column inList it as List<S> }
}
if (!filter.notIn.isNullOrEmpty()) {
opAnd.andWhere(filter.notIn) { column notInList it as List<S> }
}

return opAnd.op
}

fun <T : Comparable<T>> andFilterWithCompareEntity(
column: Column<EntityID<T>>,
filter: ComparableScalarFilter<T>?,
): Op<Boolean>? {
@Suppress("UNCHECKED_CAST")
return andFilterWithCompare(column as Column<T>, filter)
}

@Suppress("UNCHECKED_CAST")
fun <T : Comparable<T>, S : T?> andFilter(
column: Column<S>,
filter: ScalarFilter<T>?,
): Op<Boolean>? {
filter ?: return null
val opAnd = OpAnd()

opAnd.andWhere(filter.lessThan) { column less it }
opAnd.andWhere(filter.lessThanOrEqualTo) { column lessEq it }
opAnd.andWhere(filter.greaterThan) { column greater it }
opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it }

opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() }
opAnd.andWhere(filter.equalTo) { column eq it as S }
opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it as S }
opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it as S) }
opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it as S) }

opAnd.andWhere(filter.equalTo) { column eq it }
opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it }
opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it) }
opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it) }
if (!filter.`in`.isNullOrEmpty()) {
opAnd.andWhere(filter.`in`) { column inList it as List<S> }
opAnd.andWhere(filter.`in`) { column inList it }
}
if (!filter.notIn.isNullOrEmpty()) {
opAnd.andWhere(filter.notIn) { column notInList it as List<S> }
opAnd.andWhere(filter.notIn) { column notInList it }
}

return opAnd.op
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.jetbrains.exposed.sql.andWhere
import org.jetbrains.exposed.sql.or

interface OrderBy<T> {
val column: Column<out Comparable<*>>
val column: Column<*>

fun asCursor(type: T): Cursor

Expand Down

0 comments on commit ecb7982

Please sign in to comment.