From 051e03bed3241ab75c7283116201c621decca772 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 16 Nov 2020 19:46:50 +0600 Subject: [PATCH 1/3] start 0.4.1 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6a4c8d4ae..ff04f571e06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.4.1 + ## 0.4.0 * `Repos`: diff --git a/gradle.properties b/gradle.properties index aa19e374f21..c793f689a86 100644 --- a/gradle.properties +++ b/gradle.properties @@ -41,5 +41,5 @@ dokka_version=1.4.0 # Project data group=dev.inmo -version=0.4.0 -android_code_version=4 +version=0.4.1 +android_code_version=5 From 63921cd984bc1f81e1671c1486c422c34cb6178b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 16 Nov 2020 19:48:28 +0600 Subject: [PATCH 2/3] fix of shared flow size in ExposedKeyValueRepo --- CHANGELOG.md | 3 +++ .../micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff04f571e06..ff763b44fc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.4.1 +* `Repos`: + * Fixed error in `ExposedKeyValueRepo` related to negative size of shared flow + ## 0.4.0 * `Repos`: diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt index b303fa89feb..897209fa866 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt @@ -18,8 +18,8 @@ open class ExposedKeyValueRepo( valueColumnAllocator, tableName ) { - private val _onNewValue = MutableSharedFlow>(Channel.BUFFERED) - private val _onValueRemoved = MutableSharedFlow(Channel.BUFFERED) + private val _onNewValue = MutableSharedFlow>() + private val _onValueRemoved = MutableSharedFlow() override val onNewValue: Flow> = _onNewValue.asSharedFlow() override val onValueRemoved: Flow = _onValueRemoved.asSharedFlow() From 71ff0232aab4e19e66a4af9e5912ad147997027b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 16 Nov 2020 20:05:22 +0600 Subject: [PATCH 3/3] fix keyvalue exposed repo initiation --- CHANGELOG.md | 1 + .../repos/exposed/keyvalue/ExposedKeyValueRepo.kt | 1 + .../repos/exposed/keyvalue/ExposedReadKeyValueRepo.kt | 9 +++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff763b44fc0..cf47f5471f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * `Repos`: * Fixed error in `ExposedKeyValueRepo` related to negative size of shared flow + * Fixed error in `ExposedKeyValueRepo` related to avoiding of table initiation ## 0.4.0 diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt index 897209fa866..5dc80a3aa13 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedKeyValueRepo.kt @@ -2,6 +2,7 @@ package dev.inmo.micro_utils.repos.exposed.keyvalue import dev.inmo.micro_utils.repos.StandardKeyValueRepo import dev.inmo.micro_utils.repos.exposed.ColumnAllocator +import dev.inmo.micro_utils.repos.exposed.initTable import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.* import org.jetbrains.exposed.sql.* diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedReadKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedReadKeyValueRepo.kt index cec2b7b0b45..8cb3228cf47 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedReadKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/ExposedReadKeyValueRepo.kt @@ -2,8 +2,7 @@ package dev.inmo.micro_utils.repos.exposed.keyvalue import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo -import dev.inmo.micro_utils.repos.exposed.ColumnAllocator -import dev.inmo.micro_utils.repos.exposed.ExposedRepo +import dev.inmo.micro_utils.repos.exposed.* import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.transactions.transaction @@ -17,6 +16,8 @@ open class ExposedReadKeyValueRepo( protected val valueColumn: Column = valueColumnAllocator() override val primaryKey: PrimaryKey = PrimaryKey(keyColumn, valueColumn) + init { initTable() } + override suspend fun get(k: Key): Value? = transaction(database) { select { keyColumn.eq(k) }.limit(1).firstOrNull() ?.getOrNull(valueColumn) } @@ -33,8 +34,8 @@ open class ExposedReadKeyValueRepo( } }.createPaginationResult(pagination, count()) - override suspend fun keys(value: Value, pagination: Pagination, reversed: Boolean): PaginationResult = transaction(database) { - select { valueColumn.eq(value) }.let { + override suspend fun keys(v: Value, pagination: Pagination, reversed: Boolean): PaginationResult = transaction(database) { + select { valueColumn.eq(v) }.let { it.count() to it.paginate(pagination, keyColumn to if (reversed) SortOrder.DESC else SortOrder.ASC).map { it[keyColumn] }