mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-17 13:53:49 +00:00
improvements in selectByIds of CommonExposedRepo
This commit is contained in:
parent
e4b619e050
commit
2b76ad0aa9
@ -2,6 +2,10 @@
|
||||
|
||||
## 0.16.12
|
||||
|
||||
* `Repos`:
|
||||
* `Exposed`:
|
||||
* `CommonExposedRepo.selectByIds` uses `foldRight` by default instead of raw foreach
|
||||
|
||||
## 0.16.11
|
||||
|
||||
* `LanguageCodes`:
|
||||
|
@ -7,15 +7,9 @@ interface CommonExposedRepo<IdType, ObjectType> : ExposedRepo {
|
||||
val ResultRow.asId: IdType
|
||||
val selectById: ISqlExpressionBuilder.(IdType) -> Op<Boolean>
|
||||
val selectByIds: ISqlExpressionBuilder.(List<IdType>) -> Op<Boolean>
|
||||
get() = { list ->
|
||||
if (list.isEmpty()) {
|
||||
Op.FALSE
|
||||
} else {
|
||||
var op = selectById(list.first())
|
||||
(1 until list.size).forEach {
|
||||
op = op.or(selectById(list[it]))
|
||||
}
|
||||
op
|
||||
}
|
||||
get() = {
|
||||
it.foldRight<IdType, Op<Boolean>?>(null) { id, acc ->
|
||||
acc ?.or(selectById(id)) ?: selectById(id)
|
||||
} ?: Op.FALSE
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user