Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add Boolean type conversion support in JasyncRow
  • Loading branch information
Sung-Heon committed May 18, 2025
commit e447eabe672c52039fb300d483d2fbddcafbe1a3
14 changes: 14 additions & 0 deletions r2dbc-mysql/src/main/java/JasyncRow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ class JasyncRow(private val rowData: RowData, private val metadata: JasyncMetada
return when {
requestedType == Object::class.java -> value
requestedType == String::class.java -> value?.toString()
requestedType == java.lang.Boolean::class.java -> {
when (value) {
is Number -> value.toInt() != 0
is String -> value.toBoolean()
is Boolean -> value
else -> throw IllegalStateException("Cannot convert ${value?.javaClass?.simpleName} to Boolean")
}
}
value is Number -> {
when (requestedType) {
java.lang.Long::class.java -> value.toLong()
Expand All @@ -54,6 +62,12 @@ class JasyncRow(private val rowData: RowData, private val metadata: JasyncMetada
else -> throw IllegalStateException("unmatched requested type ${requestedType.simpleName}")
}
}
value is Boolean && requestedType.isPrimitive -> {
when (requestedType.name) {
"boolean" -> value
else -> throw IllegalStateException("Cannot convert Boolean to ${requestedType.name}")
}
}
value is LocalDateTime -> {
when (requestedType) {
LocalDate::class.java -> value.toLocalDate()
Expand Down