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