mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-03-14 18:42:42 +00:00
improve selectByIds and fill changelog
This commit is contained in:
parent
ce717a4c9f
commit
a8e226786d
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user