Merge pull request #75 from InsanusMokrassar/0.5.11

0.5.11
This commit is contained in:
InsanusMokrassar 2021-06-16 13:25:56 +06:00 committed by GitHub
commit b07683b815
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 2 deletions

View File

@ -1,5 +1,13 @@
# Changelog
## 0.5.11
* `Repos`:
* `Common`:
* Fixes in `WriteOneToManyRepo#add`
* `Exposed`:
* Fixes in `ExposedOneToManyKeyValueRepo#add`
## 0.5.10
* `Versions`

View File

@ -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

View File

@ -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,

View File

@ -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