The issue is basically happening, when i am comparing a string whose length is greater than 255+ with a column value, whose code is as follows,
transaction {
TableUserAccessToken.update({
(TableUserAccessToken.accessToken eq argAccessToken)
}) {
it[updatedAt] = DateTime.now()
it[isActive] = argDisableToken
}
}
Basically i want to update a row based on 3 parameters i.e.
object TableUserAccessToken : Table(name = "AccessToken") {
val createdAt = datetime("created_at").clientDefault { DateTime.now() }
val updatedAt = datetime("updated_at").nullable()
val accessToken = varchar("accessToken", MAX_COLUMN_LENGTH)
val refreshToken = varchar("refreshToken", MAX_COLUMN_LENGTH)
val isActive = bool("isActive").default(true)
val userId = integer("userId").references(TableUser.id, onDelete = ReferenceOption.CASCADE,
onUpdate = ReferenceOption.CASCADE)
}
and here it fails to update with following message as follows,
"message" : "Value 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6InJlcHJhdG9yLmtoYXRhYm9va0FjY291bnQiLCJ1c2VyUGhvbmVOdW1iZXIiOiI5MDQxODY2MDU1IiwidXNlck9yZ2FuaXphdGlvbklkIjotMSwiZXhwIjoxNjAxOTAyNTYwLCJ1c2VySWQiOjF9.q6t0_q2jaY24Y-QZMF8GYduqhtIAaYRjFyq_dhAscgI6yxZUglERzaf3j-4RGWmSZXGqgJU8FcipbW9gbo9Ygw' can't be stored to database column because exceeds length (255)"
and if i just provide one parameter it works, even if access token of 2 doesnot exist in table database, query as follows,
transaction {
TableUserAccessToken.update({
(TableUserAccessToken.accessToken eq "2")
}) {
it[updatedAt] = DateTime.now()
it[isActive] = argDisableToken
}
}
and related user table is as follows,
object TableUser : IntIdTable(name = "Users") {
val mobile = text("mobileNumber")
val verificationStatus = bool("isVerified").default(false)
val parentId = integer("parentId").default(-1)
val createdAt = datetime("created_at").clientDefault { DateTime.now() }
}
But i have to update based on multiple conditions, It will be very great, if you guys could assist me.
Table Creation Logs,
CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, "mobileNumber" TEXT NOT NULL, "isVerified" BOOLEAN DEFAULT false NOT NULL, "parentId" INT DEFAULT -1 NOT NULL, created_at TIMESTAMP NOT NULL)
CREATE TABLE IF NOT EXISTS accesstoken (created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NULL, "accessToken" VARCHAR(1000) NOT NULL, "refreshToken" VARCHAR(1000) NOT NULL, "isActive" BOOLEAN DEFAULT true NOT NULL, "userId" INT NOT NULL, CONSTRAINT fk_accesstoken_userid_id FOREIGN KEY ("userId") REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE)
Account Creation Exposed logs for api(/api/v1/accounts),
SELECT users.id, users."mobileNumber", users."isVerified", users."parentId", users.created_at FROM users WHERE (users."mobileNumber" = '9041866055') AND (users."parentId" = -1) LIMIT 1
INSERT INTO users (created_at, "isVerified", "mobileNumber", "parentId") VALUES ('2020-10-05 20:57:47.393000', false, '9041866055', -1)
INSERT INTO accesstoken ("accessToken", created_at, "isActive", "refreshToken", updated_at, "userId") VALUES ('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6InJlcHJhdG9yLmtoYXRhYm9va0FjY291bnQiLCJ1c2VyUGhvbmVOdW1iZXIiOiI5MDQxODY2MDU1IiwidXNlck9yZ2FuaXphdGlvbklkIjotMSwiZXhwIjoxNjAxOTk4MDY3LCJ1c2VySWQiOjF9.BQ2iYk03cSrvwEQ4XGmrlZHsiZXVooiwink7uIQ1YiqaSlcaOJCV9peNoq7UC_1I2WvYPBB6epvDCINwcPXhWA', '2020-10-05 20:57:47.483000', true, 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6InJlcHJhdG9yLmtoYXRhYm9va0FjY291bnQiLCJ1c2VyUGhvbmVOdW1iZXIiOiI5MDQxODY2MDU1IiwidXNlck9yZ2FuaXphdGlvbklkIjotMSwiZXhwIjoxNjAyNzc1NjY3LCJ1c2VySWQiOjF9.F3ktJodIwNpkmtl6rLNT5IbzbRLZxs5QZN4N8mqlxd8pb-7eUx0Fx_AQj88M0JqQ_P40fS91ya6DGztjjqBwOg', NULL, 1)
Refresh Token Logs for api(/api/v1/accounts/refreshToken), Crash Log for exposed as follows,
ERROR r.k.error.ErrorFeature - Caught exception: Value 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6InJlcHJhdG9yLmtoYXRhYm9va0FjY291bnQiLCJ1c2VyUGhvbmVOdW1iZXIiOiI5MDQxODY2MDU1IiwidXNlck9yZ2FuaXphdGlvbklkIjotMSwiZXhwIjoxNjAxOTk4MDY3LCJ1c2VySWQiOjF9.BQ2iYk03cSrvwEQ4XGmrlZHsiZXVooiwink7uIQ1YiqaSlcaOJCV9peNoq7UC_1I2WvYPBB6epvDCINwcPXhWA' can't be stored to database column because exceeds length (255)
java.lang.IllegalArgumentException: Value 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6InJlcHJhdG9yLmtoYXRhYm9va0FjY291bnQiLCJ1c2VyUGhvbmVOdW1iZXIiOiI5MDQxODY2MDU1IiwidXNlck9yZ2FuaXphdGlvbklkIjotMSwiZXhwIjoxNjAxOTk4MDY3LCJ1c2VySWQiOjF9.BQ2iYk03cSrvwEQ4XGmrlZHsiZXVooiwink7uIQ1YiqaSlcaOJCV9peNoq7UC_1I2WvYPBB6epvDCINwcPXhWA' can't be stored to database column because exceeds length (255)
at org.jetbrains.exposed.sql.VarCharColumnType.notNullValueToDB(ColumnType.kt:541)
at org.jetbrains.exposed.sql.IColumnType$DefaultImpls.valueToDB(ColumnType.kt:37)
at org.jetbrains.exposed.sql.ColumnType.valueToDB(ColumnType.kt:71)
at org.jetbrains.exposed.sql.statements.api.PreparedStatementApi$DefaultImpls.fillParameters(PreparedStatementApi.kt:13)
at org.jetbrains.exposed.sql.statements.jdbc.JdbcPreparedStatementImpl.fillParameters(JdbcPreparedStatementImpl.kt:9)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:53)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:129)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:115)
at org.jetbrains.exposed.sql.statements.Statement.execute(Statement.kt:29)
at org.jetbrains.exposed.sql.QueriesKt.update(Queries.kt:179)
at org.jetbrains.exposed.sql.QueriesKt.update$default(Queries.kt:176)
at reprator.khatabookAccount.accountService.data.db.DbAccountAccessTokenRepository$updateUserToken$2.invoke(DbAccountAccessTokenRepository.kt:35)
at reprator.khatabookAccount.accountService.data.db.DbAccountAccessTokenRepository$updateUserToken$2.invoke(DbAccountAccessTokenRepository.kt:12)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$1.invoke(ThreadLocalTransactionManager.kt:170)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$2.invoke(ThreadLocalTransactionManager.kt:211)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:219)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:210)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$transaction$1.invoke(ThreadLocalTransactionManager.kt:148)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:219)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:120)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:118)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction$default(ThreadLocalTransactionManager.kt:117)
at reprator.khatabookAccount.accountService.data.db.DbAccountAccessTokenRepository.updateUserToken(DbAccountAccessTokenRepository.kt:34)
at reprator.khatabookAccount.accountService.data.AccountAccessTokenRepository$DefaultImpls.updateUserToken$default(AccountAccessTokenRepository.kt:16)
at reprator.khatabookAccount.accountService.domain.default.DefaultAccountResourceFactory.refreshToken(DefaultAccountResourceFactory.kt:83)
at reprator.khatabookAccount.accountService.domain.default.DefaultAccountFacade.refreshToken(DefaultAccountFacade.kt:37)
at reprator.khatabookAccount.accountService.controller.default.DefaultAccountController.refreshToken(DefaultAccountController.kt:32)
at reprator.khatabookAccount.accountService.controller.AbstractAccountController$getRoutes$2$1.invokeSuspend(AbstractAccountController.kt:25)
at reprator.khatabookAccount.accountService.controller.AbstractAccountController$getRoutes$2$1.invoke(AbstractAccountController.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:323)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:168)
at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:188)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:31)
at io.ktor.routing.Routing.executeResult(Routing.kt:147)
at io.ktor.routing.Routing.interceptor(Routing.kt:34)
at io.ktor.routing.Routing$Feature$install$1.invokeSuspend(Routing.kt:99)
at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:323)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:168)
at io.ktor.features.ContentNegotiation$Feature$install$1.invokeSuspend(ContentNegotiation.kt:107)
at io.ktor.features.ContentNegotiation$Feature$install$1.invoke(ContentNegotiation.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:323)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:168)
at io.ktor.features.StatusPages$interceptCall$2.invokeSuspend(StatusPages.kt:101)
at io.ktor.features.StatusPages$interceptCall$2.invoke(StatusPages.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:194)
at io.ktor.features.StatusPages.interceptCall(StatusPages.kt:100)
at io.ktor.features.StatusPages$Feature$install$2.invokeSuspend(StatusPages.kt:140)
at io.ktor.features.StatusPages$Feature$install$2.invoke(StatusPages.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:323)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:168)
at io.ktor.features.CallLogging$Feature$install$1$invokeSuspend$$inlined$withMDC$1.invokeSuspend(CallLogging.kt:226)
at io.ktor.features.CallLogging$Feature$install$1$invokeSuspend$$inlined$withMDC$1.invoke(CallLogging.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:160)
at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
at io.ktor.features.CallLogging$Feature$install$1.invokeSuspend(CallLogging.kt:230)
at io.ktor.features.CallLogging$Feature$install$1.invoke(CallLogging.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:323)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:168)
at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:188)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:31)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invokeSuspend(DefaultEnginePipeline.kt:121)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:323)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:168)
at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:188)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:31)
at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invokeSuspend(NettyApplicationCallHandler.kt:40)
at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:111)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
at io.ktor.server.netty.NettyApplicationCallHandler.handleRequest(NettyApplicationCallHandler.kt:30)
at io.ktor.server.netty.NettyApplicationCallHandler.channelRead(NettyApplicationCallHandler.kt:24)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61)
at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:370)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
My DB is: Postgres, version is 42.2.16,
JDBC DRIVER version 0.27.1
Exposed version 0.27.1
MAX_COLUMN_LENGTH = 1000
The whole source code can be found here, https://github.com/TheReprator/khatabookAccount
This is the actual issue, https://github.com/JetBrains/Exposed/issues/1029