improve selectByIds and fill changelog

This commit is contained in:
InsanusMokrassar 2025-01-17 19:46:29 +06:00
parent ce717a4c9f
commit a8e226786d
2 changed files with 17 additions and 3 deletions
CHANGELOG.md
repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed

@ -2,6 +2,12 @@
## 0.24.4
* `Repos`:
* `Exposed`:
* Improve `CommonExposedRepo.selectByIds`
* `FSM`:
* Fixes and improvements
## 0.24.3
* `Ksp`:

@ -8,8 +8,16 @@ interface CommonExposedRepo<IdType, ObjectType> : ExposedRepo {
val selectById: ISqlExpressionBuilder.(IdType) -> Op<Boolean>
val selectByIds: ISqlExpressionBuilder.(List<IdType>) -> Op<Boolean>
get() = {
it.foldRight<IdType, Op<Boolean>?>(null) { id, acc ->
acc ?.or(selectById(id)) ?: selectById(id)
} ?: Op.FALSE
if (it.isEmpty()) {
Op.FALSE
} else {
var op = it.firstOrNull() ?.let { selectById(it) } ?: Op.FALSE
var i = 1
while (i < it.size) {
op = op.or(selectById(it[i]))
i++
}
op
}
}
}