clickhouse-java
clickhouse-java copied to clipboard
[client-v2] No serializer found for Boolean column in kotlin class
Description
Steps to reproduce
- Table:
CREATE TABLE test_table
(
my_id Int64,
is_bool Boolean
) ENGINE = ReplacingMergeTree
ORDER BY (my_id);
- Kotlin data class:
data class TestRecord(
val myId: Int,
val isBool: Boolean,
)
- Repository class:
private const val TEST_TABLE_NAME = "test_table"
@Repository
class TestRepository(
private val clickHouseClient: Client,
) : CampaignStatisticRepository(clickHouseClient) {
@PostConstruct
fun init() {
clickHouseClient.register(
TestRecord::class.java,
clickHouseClient.getTableSchema(TEST_TABLE_NAME),
)
}
fun save(data: List<TestRecord>) {
if (data.isEmpty()) {
return
}
clickHouseClient.insert(TEST_TABLE_NAME, data).get().close()
}
}
- On calling
::saveI get an exception
Error Log or Exception StackTrace
No serializer found for column 'is_bool'. Did you forget to register it?
- I come across this exception only for Boolean type
- It doesn't work with "isBool" column name either
- "isbool" works (when it's a column name and a class field)
So there's a problem when I have an underscore or capital letter
Environment
- Client version: 0.8.6
- Language version: kotlin 2.1.21
So there's a problem when I have an underscore or capital letter
Actually, there's a problem with "is"
In java getter name is getIsBool, but in kotlin it's isBool
Good day, @BOOMeranGG! Thank you for reporting the issue! We will look into it.
btw, you may customize methods matching with com.clickhouse.client.api.Client.Builder#columnToMethodMatchingStrategy .