diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6a4c8d4ae..cf47f5471f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.4.1 + +* `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 * `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 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..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.* @@ -18,8 +19,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() 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] }