Fix not All/Any filters (#2064)

Both filters were inversed. `notAll` did what `notAny` was supposed to do and vise versa

Co-authored-by: Mitchell Syer <Syer10@users.noreply.github.com>
This commit is contained in:
schroda
2026-05-21 02:15:45 +02:00
committed by GitHub
parent 701e4674ea
commit 6493eaaa02
2 changed files with 39 additions and 11 deletions

View File

@@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- (**Chapter**) Fix losing chapter data on failed chapter list update - (**Chapter**) Fix losing chapter data on failed chapter list update
- (**Chapter**) Fix database error when fetching chapter updates - (**Chapter**) Fix database error when fetching chapter updates
- (**Manga/API**) Fix "mangas" graphql query with active sorting and using a postgresql database (QUERY "mangas") - (**Manga/API**) Fix "mangas" graphql query with active sorting and using a postgresql database (QUERY "mangas")
- (**API**) Fix GraphQL `Filter` `notAll` and `notAny` being inversed
- (**API**) Fix GraphQL `Filter` causing an UnsupportedOperationException when passing an empty list as a `Any` filter value - (**API**) Fix GraphQL `Filter` causing an UnsupportedOperationException when passing an empty list as a `Any` filter value
## [v2.2.2100] + [WebUI: v20260508.01] - 2026-05-08 ## [v2.2.2100] + [WebUI: v20260508.01] - 2026-05-08

View File

@@ -435,7 +435,7 @@ fun <T : String, S : T?> andFilterWithCompareString(
opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() } opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() }
opAnd.andWhere(filter.equalTo) { column eq it as S } opAnd.andWhere(filter.equalTo) { column eq it as S }
opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it as S } opAnd.andNotWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it as S }
opAnd.andWhere( opAnd.andWhere(
filter.distinctFrom, filter.distinctFrom,
filter.distinctFromAll, filter.distinctFromAll,
@@ -455,36 +455,36 @@ fun <T : String, S : T?> andFilterWithCompareString(
opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it } opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it }
opAnd.andWhere(filter.includes, filter.includesAll, filter.includesAny) { column like "%$it%" } opAnd.andWhere(filter.includes, filter.includesAll, filter.includesAny) { column like "%$it%" }
opAnd.andWhere(filter.notIncludes, filter.notIncludesAll, filter.notIncludesAny) { column notLike "%$it%" } opAnd.andNotWhere(filter.notIncludes, filter.notIncludesAll, filter.notIncludesAny) { column notLike "%$it%" }
opAnd.andWhere(filter.includesInsensitive, filter.includesInsensitiveAll, filter.includesInsensitiveAny) { opAnd.andWhere(filter.includesInsensitive, filter.includesInsensitiveAll, filter.includesInsensitiveAny) {
ILikeEscapeOp.iLike(column, "%$it%") ILikeEscapeOp.iLike(column, "%$it%")
} }
opAnd.andWhere(filter.notIncludesInsensitive, filter.notIncludesInsensitiveAll, filter.notIncludesInsensitiveAny) { opAnd.andNotWhere(filter.notIncludesInsensitive, filter.notIncludesInsensitiveAll, filter.notIncludesInsensitiveAny) {
ILikeEscapeOp.iNotLike(column, "%$it%") ILikeEscapeOp.iNotLike(column, "%$it%")
} }
opAnd.andWhere(filter.startsWith, filter.startsWithAll, filter.startsWithAny) { column like "$it%" } opAnd.andWhere(filter.startsWith, filter.startsWithAll, filter.startsWithAny) { column like "$it%" }
opAnd.andWhere(filter.notStartsWith, filter.notStartsWithAll, filter.notStartsWithAny) { column notLike "$it%" } opAnd.andNotWhere(filter.notStartsWith, filter.notStartsWithAll, filter.notStartsWithAny) { column notLike "$it%" }
opAnd.andWhere(filter.startsWithInsensitive, filter.startsWithInsensitiveAll, filter.startsWithInsensitiveAny) { opAnd.andWhere(filter.startsWithInsensitive, filter.startsWithInsensitiveAll, filter.startsWithInsensitiveAny) {
ILikeEscapeOp.iLike(column, "$it%") ILikeEscapeOp.iLike(column, "$it%")
} }
opAnd.andWhere(filter.notStartsWithInsensitive, filter.notStartsWithInsensitiveAll, filter.notStartsWithInsensitiveAny) { opAnd.andNotWhere(filter.notStartsWithInsensitive, filter.notStartsWithInsensitiveAll, filter.notStartsWithInsensitiveAny) {
ILikeEscapeOp.iNotLike(column, "$it%") ILikeEscapeOp.iNotLike(column, "$it%")
} }
opAnd.andWhere(filter.endsWith, filter.endsWithAll, filter.endsWithAny) { column like "%$it" } opAnd.andWhere(filter.endsWith, filter.endsWithAll, filter.endsWithAny) { column like "%$it" }
opAnd.andWhere(filter.notEndsWith, filter.notEndsWithAll, filter.notEndsWithAny) { column notLike "%$it" } opAnd.andNotWhere(filter.notEndsWith, filter.notEndsWithAll, filter.notEndsWithAny) { column notLike "%$it" }
opAnd.andWhere(filter.endsWithInsensitive, filter.endsWithInsensitiveAll, filter.endsWithInsensitiveAny) { opAnd.andWhere(filter.endsWithInsensitive, filter.endsWithInsensitiveAll, filter.endsWithInsensitiveAny) {
ILikeEscapeOp.iLike(column, "%$it") ILikeEscapeOp.iLike(column, "%$it")
} }
opAnd.andWhere(filter.notEndsWithInsensitive, filter.notEndsWithInsensitiveAll, filter.notEndsWithInsensitiveAny) { opAnd.andNotWhere(filter.notEndsWithInsensitive, filter.notEndsWithInsensitiveAll, filter.notEndsWithInsensitiveAny) {
ILikeEscapeOp.iNotLike(column, "%$it") ILikeEscapeOp.iNotLike(column, "%$it")
} }
opAnd.andWhere(filter.like, filter.likeAll, filter.likeAny) { column like it } opAnd.andWhere(filter.like, filter.likeAll, filter.likeAny) { column like it }
opAnd.andWhere(filter.notLike, filter.notLikeAll, filter.notLikeAny) { column notLike it } opAnd.andNotWhere(filter.notLike, filter.notLikeAll, filter.notLikeAny) { column notLike it }
opAnd.andWhere(filter.likeInsensitive, filter.likeInsensitiveAll, filter.likeInsensitiveAny) { ILikeEscapeOp.iLike(column, it) } opAnd.andWhere(filter.likeInsensitive, filter.likeInsensitiveAll, filter.likeInsensitiveAny) { ILikeEscapeOp.iLike(column, it) }
opAnd.andWhere(filter.notLikeInsensitive, filter.notLikeInsensitiveAll, filter.notLikeInsensitiveAny) { opAnd.andNotWhere(filter.notLikeInsensitive, filter.notLikeInsensitiveAll, filter.notLikeInsensitiveAny) {
ILikeEscapeOp.iNotLike(column, it) ILikeEscapeOp.iNotLike(column, it)
} }
@@ -535,6 +535,17 @@ class OpAnd(
andWhereAny(valueAny, expr) andWhereAny(valueAny, expr)
} }
fun <T : Any> andNotWhere(
valueDefault: T?,
valueAll: List<T>?,
valueAny: List<T>?,
expr: (T) -> Op<Boolean>,
) {
andWhere(valueDefault, expr)
andNotWhereAll(valueAll, expr)
andNotWhereAny(valueAny, expr)
}
fun <T : Any> andWhereAll( fun <T : Any> andWhereAll(
values: List<T>?, values: List<T>?,
andPart: (T) -> Op<Boolean>, andPart: (T) -> Op<Boolean>,
@@ -542,6 +553,14 @@ class OpAnd(
values?.map { andWhere(it, andPart) } values?.map { andWhere(it, andPart) }
} }
fun <T : Any> andNotWhereAll(
values: List<T>?,
andPart: (T) -> Op<Boolean>,
) {
// Inversed all equals any
andWhereAny(values, andPart)
}
fun <T : Any> andWhereAny( fun <T : Any> andWhereAny(
values: List<T>?, values: List<T>?,
andPart: (T) -> Op<Boolean>, andPart: (T) -> Op<Boolean>,
@@ -551,6 +570,14 @@ class OpAnd(
op = if (op == null) expr else (op!! and expr) op = if (op == null) expr else (op!! and expr)
} }
fun <T : Any> andNotWhereAny(
values: List<T>?,
andPart: (T) -> Op<Boolean>,
) {
// Inversed any equals all
andWhereAll(values, andPart)
}
fun <T> eq( fun <T> eq(
value: T?, value: T?,
column: Column<T>, column: Column<T>,
@@ -578,7 +605,7 @@ fun <T : Comparable<T>, S : T?> andFilterWithCompare(
opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() } opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() }
opAnd.andWhere(filter.equalTo) { column eq it as S } opAnd.andWhere(filter.equalTo) { column eq it as S }
opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it as S } opAnd.andNotWhere(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.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it as S) }
opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it as S) } opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it as S) }
if (!filter.`in`.isNullOrEmpty()) { if (!filter.`in`.isNullOrEmpty()) {
@@ -606,7 +633,7 @@ fun <T : Comparable<T>> andFilterWithCompareEntity(
opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() } opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() }
opAnd.andWhere(filter.equalTo) { column eq it } opAnd.andWhere(filter.equalTo) { column eq it }
opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it } opAnd.andNotWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it }
opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it) } opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it) }
opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it) } opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it) }
if (!filter.`in`.isNullOrEmpty()) { if (!filter.`in`.isNullOrEmpty()) {