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,