From c47c7b09f435b526875bb74ec831a15b622313e5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Oct 2022 12:46:31 +0600 Subject: [PATCH] fixes in exposed tables --- .../kotlin/repos/ExposedPollsToMessagesInfoRepo.kt | 9 +++------ .../jvmMain/kotlin/repos/ExposedPollsToPostsIdsRepo.kt | 8 +++----- ratings/src/jvmMain/kotlin/exposed/ExposedRatingsRepo.kt | 8 +++----- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToMessagesInfoRepo.kt b/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToMessagesInfoRepo.kt index bd0f9d3..7f73962 100644 --- a/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToMessagesInfoRepo.kt +++ b/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToMessagesInfoRepo.kt @@ -6,8 +6,7 @@ import dev.inmo.plaguposter.common.ShortMessageInfo import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.PollIdentifier import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.statements.InsertStatement -import org.jetbrains.exposed.sql.statements.UpdateStatement +import org.jetbrains.exposed.sql.statements.* class ExposedPollsToMessagesInfoRepo( database: Database @@ -36,14 +35,12 @@ class ExposedPollsToMessagesInfoRepo( initTable() } - override fun update(k: PollIdentifier, v: ShortMessageInfo, it: UpdateStatement) { + override fun update(k: PollIdentifier, v: ShortMessageInfo, it: UpdateBuilder) { it[chatIdColumn] = v.chatId.chatId it[messageIdColumn] = v.messageId } - override fun insert(k: PollIdentifier, v: ShortMessageInfo, it: InsertStatement) { + override fun insertKey(k: PollIdentifier, v: ShortMessageInfo, it: InsertStatement) { it[keyColumn] = k - it[chatIdColumn] = v.chatId.chatId - it[messageIdColumn] = v.messageId } } diff --git a/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToPostsIdsRepo.kt b/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToPostsIdsRepo.kt index 66a7ba4..fce2b48 100644 --- a/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToPostsIdsRepo.kt +++ b/ratings/source/src/jvmMain/kotlin/repos/ExposedPollsToPostsIdsRepo.kt @@ -5,8 +5,7 @@ import dev.inmo.micro_utils.repos.exposed.keyvalue.AbstractExposedKeyValueRepo import dev.inmo.plaguposter.posts.models.PostId import dev.inmo.tgbotapi.types.PollIdentifier import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.statements.InsertStatement -import org.jetbrains.exposed.sql.statements.UpdateStatement +import org.jetbrains.exposed.sql.statements.* class ExposedPollsToPostsIdsRepo( database: Database @@ -24,12 +23,11 @@ class ExposedPollsToPostsIdsRepo( initTable() } - override fun update(k: PollIdentifier, v: PostId, it: UpdateStatement) { + override fun update(k: PollIdentifier, v: PostId, it: UpdateBuilder) { it[postIdColumn] = v.string } - override fun insert(k: PollIdentifier, v: PostId, it: InsertStatement) { + override fun insertKey(k: PollIdentifier, v: PostId, it: InsertStatement) { it[keyColumn] = k - it[postIdColumn] = v.string } } diff --git a/ratings/src/jvmMain/kotlin/exposed/ExposedRatingsRepo.kt b/ratings/src/jvmMain/kotlin/exposed/ExposedRatingsRepo.kt index d49936e..0f0799f 100644 --- a/ratings/src/jvmMain/kotlin/exposed/ExposedRatingsRepo.kt +++ b/ratings/src/jvmMain/kotlin/exposed/ExposedRatingsRepo.kt @@ -6,8 +6,7 @@ import dev.inmo.plaguposter.posts.models.PostId import dev.inmo.plaguposter.ratings.models.Rating import dev.inmo.plaguposter.ratings.repo.RatingsRepo import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.statements.InsertStatement -import org.jetbrains.exposed.sql.statements.UpdateStatement +import org.jetbrains.exposed.sql.statements.* import org.jetbrains.exposed.sql.transactions.transaction class ExposedRatingsRepo ( @@ -25,13 +24,12 @@ class ExposedRatingsRepo ( override val ResultRow.asObject: Rating get() = get(ratingsColumn).let(::Rating) - override fun update(k: PostId, v: Rating, it: UpdateStatement) { + override fun update(k: PostId, v: Rating, it: UpdateBuilder) { it[ratingsColumn] = v.double } - override fun insert(k: PostId, v: Rating, it: InsertStatement) { + override fun insertKey(k: PostId, v: Rating, it: InsertStatement) { it[keyColumn] = k.string - it[ratingsColumn] = v.double } private fun Query.optionallyLimit(limit: Int?) = if (limit == null) {