https://kotlinlang.org logo
#komapper
Title
# komapper
d

dave08

01/17/2023, 4:54 PM
In sql templates, if you get the bind param name wrong, it puts out a VERY cryptic error that it can't resolve a data type
Any
....!
t

Toshihiro Nakamura

01/18/2023, 11:32 AM
Can you show me your code and stack trace? I would also like to know if you are using JDBC or R2DBC.
d

dave08

01/18/2023, 11:33 AM
r2dbc
I'll try to reproduce now
Copy code
The dataType is not found for the type "kotlin.Any".
java.lang.IllegalStateException: The dataType is not found for the type "kotlin.Any".
	at org.komapper.r2dbc.DefaultR2dbcDataOperator.getDataType(R2dbcDataOperator.kt:79)
	at org.komapper.r2dbc.DefaultR2dbcDataOperator.formatValue(R2dbcDataOperator.kt:72)
	at org.komapper.r2dbc.R2dbcExecutor$log$2.invoke(R2dbcExecutor.kt:172)
	at org.komapper.r2dbc.R2dbcExecutor$log$2.invoke(R2dbcExecutor.kt:172)
	at org.komapper.core.Statement$toSqlWithArgs$1.invoke(Statement.kt:58)
	at org.komapper.core.Statement$toSqlWithArgs$1.invoke(Statement.kt:53)
	at kotlin.text.StringsKt__AppendableKt.appendElement(Appendable.kt:85)
	at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:3490)
	at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:3507)
	at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:3506)
	at org.komapper.core.Statement.toSqlWithArgs(Statement.kt:53)
	at org.komapper.core.DefaultLoggerFacade$sqlWithArgs$1.invoke(LoggerFacade.kt:99)
	at org.komapper.core.DefaultLoggerFacade$sqlWithArgs$1.invoke(LoggerFacade.kt:98)
	at org.komapper.slf4j.Slf4jLoggerAdapter.trace(Slf4jLoggerAdapter.kt:11)
	at org.komapper.core.DefaultLoggerFacade.sqlWithArgs(LoggerFacade.kt:98)
	at org.komapper.r2dbc.R2dbcExecutor.log(R2dbcExecutor.kt:172)
	at org.komapper.r2dbc.R2dbcExecutor.access$log(R2dbcExecutor.kt:21)
	at org.komapper.r2dbc.R2dbcExecutor$executeQuery$1$1.invokeSuspend(R2dbcExecutor.kt:39)
	at org.komapper.r2dbc.R2dbcExecutor$executeQuery$1$1.invoke(R2dbcExecutor.kt)
	at org.komapper.r2dbc.R2dbcExecutor$executeQuery$1$1.invoke(R2dbcExecutor.kt)
	at org.komapper.r2dbc.R2dbcSession$DefaultImpls.useConnection(R2dbcSession.kt:38)
	at org.komapper.tx.r2dbc.R2dbcTransactionSession.useConnection(R2dbcTransactionSession.kt:16)
	at org.komapper.r2dbc.R2dbcExecutor$executeQuery$1.invokeSuspend(R2dbcExecutor.kt:36)
	at org.komapper.r2dbc.R2dbcExecutor$executeQuery$1.invoke(R2dbcExecutor.kt)
	at org.komapper.r2dbc.R2dbcExecutor$executeQuery$1.invoke(R2dbcExecutor.kt)
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
	at kotlinx.coroutines.flow.FlowKt__ErrorsKt.catchImpl(Errors.kt:156)
	at kotlinx.coroutines.flow.FlowKt.catchImpl(Unknown Source)
	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:113)
	at kotlinx.coroutines.flow.FlowKt__CollectionKt.toCollection(Collection.kt:26)
	at kotlinx.coroutines.flow.FlowKt.toCollection(Unknown Source)
	at kotlinx.coroutines.flow.FlowKt__CollectionKt.toList(Collection.kt:15)
	at kotlinx.coroutines.flow.FlowKt.toList(Unknown Source)
	at kotlinx.coroutines.flow.FlowKt__CollectionKt.toList$default(Collection.kt:15)
	at kotlinx.coroutines.flow.FlowKt.toList$default(Unknown Source)
	at org.komapper.core.dsl.query.ListQuery$accept$1.invokeSuspend(Query.kt:51)
	at org.komapper.core.dsl.query.ListQuery$accept$1.invoke(Query.kt)
	at org.komapper.core.dsl.query.ListQuery$accept$1.invoke(Query.kt)
	at org.komapper.r2dbc.dsl.runner.R2dbcTemplateSelectRunner.run(R2dbcTemplateSelectRunner.kt:24)
	at org.komapper.r2dbc.R2dbcDatabaseImpl.runQuery(R2dbcDatabase.kt:105)
No indication that the problem is the name of the bind that doesn't match the name in the sql template, it would have helped to know which placeholders were expected and which binds were provided... also no clue as to which sql template failed, my luck is that I only have one so far... no it actually does give the line in the repository later on in the stack trace... but it's still cryptic.
t

Toshihiro Nakamura

01/18/2023, 11:40 AM
Thank you. We will improve the error message.
This pull request solves the problem. https://github.com/komapper/komapper/pull/858
25 Views