mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-17 22:03:50 +00:00
commit
b07683b815
@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 0.5.11
|
||||
|
||||
* `Repos`:
|
||||
* `Common`:
|
||||
* Fixes in `WriteOneToManyRepo#add`
|
||||
* `Exposed`:
|
||||
* Fixes in `ExposedOneToManyKeyValueRepo#add`
|
||||
|
||||
## 0.5.10
|
||||
|
||||
* `Versions`
|
||||
|
@ -45,5 +45,5 @@ dokka_version=1.4.32
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.5.10
|
||||
android_code_version=51
|
||||
version=0.5.11
|
||||
android_code_version=52
|
||||
|
@ -55,6 +55,17 @@ class OneToManyAndroidRepo<Key, Value>(
|
||||
helper.blockingWritableTransaction {
|
||||
for ((k, values) in toAdd) {
|
||||
values.forEach { v ->
|
||||
val kAsString = k.keyAsString()
|
||||
val vAsString = v.valueAsString()
|
||||
val isThere = select(tableName,
|
||||
null,
|
||||
"$idColumnName=? AND $valueColumnName=?",
|
||||
arrayOf(kAsString, vAsString),
|
||||
limit = limitClause(1)
|
||||
).use { it.moveToFirst() }
|
||||
if (isThere) {
|
||||
return@forEach
|
||||
}
|
||||
insert(
|
||||
tableName,
|
||||
null,
|
||||
|
@ -31,6 +31,9 @@ open class ExposedOneToManyKeyValueRepo<Key, Value>(
|
||||
transaction(database) {
|
||||
toAdd.keys.flatMap { k ->
|
||||
toAdd[k] ?.mapNotNull { v ->
|
||||
if (select { keyColumn.eq(k).and(valueColumn.eq(v)) }.limit(1).count() > 0) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
insertIgnore {
|
||||
it[keyColumn] = k
|
||||
it[valueColumn] = v
|
||||
|
Loading…
Reference in New Issue
Block a user