fixes in exposed tables

This commit is contained in:
InsanusMokrassar 2022-10-25 12:46:31 +06:00
parent 4c8c93c9f8
commit c47c7b09f4
3 changed files with 9 additions and 16 deletions

View File

@ -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<Int>) {
it[chatIdColumn] = v.chatId.chatId
it[messageIdColumn] = v.messageId
}
override fun insert(k: PollIdentifier, v: ShortMessageInfo, it: InsertStatement<Number>) {
override fun insertKey(k: PollIdentifier, v: ShortMessageInfo, it: InsertStatement<Number>) {
it[keyColumn] = k
it[chatIdColumn] = v.chatId.chatId
it[messageIdColumn] = v.messageId
}
}

View File

@ -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<Int>) {
it[postIdColumn] = v.string
}
override fun insert(k: PollIdentifier, v: PostId, it: InsertStatement<Number>) {
override fun insertKey(k: PollIdentifier, v: PostId, it: InsertStatement<Number>) {
it[keyColumn] = k
it[postIdColumn] = v.string
}
}

View File

@ -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<Int>) {
it[ratingsColumn] = v.double
}
override fun insert(k: PostId, v: Rating, it: InsertStatement<Number>) {
override fun insertKey(k: PostId, v: Rating, it: InsertStatement<Number>) {
it[keyColumn] = k.string
it[ratingsColumn] = v.double
}
private fun Query.optionallyLimit(limit: Int?) = if (limit == null) {