mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 06:40:07 +00:00
commit
b07683b815
@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.5.11
|
||||||
|
|
||||||
|
* `Repos`:
|
||||||
|
* `Common`:
|
||||||
|
* Fixes in `WriteOneToManyRepo#add`
|
||||||
|
* `Exposed`:
|
||||||
|
* Fixes in `ExposedOneToManyKeyValueRepo#add`
|
||||||
|
|
||||||
## 0.5.10
|
## 0.5.10
|
||||||
|
|
||||||
* `Versions`
|
* `Versions`
|
||||||
|
@ -45,5 +45,5 @@ dokka_version=1.4.32
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.5.10
|
version=0.5.11
|
||||||
android_code_version=51
|
android_code_version=52
|
||||||
|
@ -55,6 +55,17 @@ class OneToManyAndroidRepo<Key, Value>(
|
|||||||
helper.blockingWritableTransaction {
|
helper.blockingWritableTransaction {
|
||||||
for ((k, values) in toAdd) {
|
for ((k, values) in toAdd) {
|
||||||
values.forEach { v ->
|
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(
|
insert(
|
||||||
tableName,
|
tableName,
|
||||||
null,
|
null,
|
||||||
|
@ -31,6 +31,9 @@ open class ExposedOneToManyKeyValueRepo<Key, Value>(
|
|||||||
transaction(database) {
|
transaction(database) {
|
||||||
toAdd.keys.flatMap { k ->
|
toAdd.keys.flatMap { k ->
|
||||||
toAdd[k] ?.mapNotNull { v ->
|
toAdd[k] ?.mapNotNull { v ->
|
||||||
|
if (select { keyColumn.eq(k).and(valueColumn.eq(v)) }.limit(1).count() > 0) {
|
||||||
|
return@mapNotNull null
|
||||||
|
}
|
||||||
insertIgnore {
|
insertIgnore {
|
||||||
it[keyColumn] = k
|
it[keyColumn] = k
|
||||||
it[valueColumn] = v
|
it[valueColumn] = v
|
||||||
|
Loading…
Reference in New Issue
Block a user