mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-12-22 05:57:13 +00:00
fixes in exposed tables
This commit is contained in:
parent
4c8c93c9f8
commit
c47c7b09f4
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user