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