From c3156f2e41c6cd3ec3d79d61833d5a4abd49509d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 16 Jun 2021 13:15:25 +0600 Subject: [PATCH 1/3] strt 0.5.11 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b1a58daec..b14d5feb055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.5.11 + ## 0.5.10 * `Versions` diff --git a/gradle.properties b/gradle.properties index cb88500f55d..29762518c81 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 From 261d8827e37b5278ebdea928c9846fba7ec8d36a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 16 Jun 2021 13:19:59 +0600 Subject: [PATCH 2/3] OneToMany fixes --- CHANGELOG.md | 4 ++++ .../repos/onetomany/OneToManyAndroidRepo.kt | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b14d5feb055..98e681e5881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.5.11 +* `Repos`: + * `Common`: + * Fixes in `WriteOneToManyRepo#add` + ## 0.5.10 * `Versions` diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt index 31c7be0ac99..1cc184fc2b4 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/onetomany/OneToManyAndroidRepo.kt @@ -55,6 +55,17 @@ class OneToManyAndroidRepo( 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, From 96e97d16919ef3922151102e913c4b265096fa78 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 16 Jun 2021 13:22:40 +0600 Subject: [PATCH 3/3] ExposedOneToManyKeyValueRepo fixes --- CHANGELOG.md | 2 ++ .../repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e681e5881..6d9502cc327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * `Repos`: * `Common`: * Fixes in `WriteOneToManyRepo#add` + * `Exposed`: + * Fixes in `ExposedOneToManyKeyValueRepo#add` ## 0.5.10 diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt index 86a4cb020cd..9d327ac846c 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/ExposedOneToManyKeyValueRepo.kt @@ -31,6 +31,9 @@ open class ExposedOneToManyKeyValueRepo( 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