Skip to content

client.insert(...) fails if registered class doesn't match all existing columns #2118

@gabrielpablorc

Description

@gabrielpablorc

Describe the bug

Attempting an insert fails if any column from the target table is not defined in the registered POJO.

Steps to reproduce

  1. Register a POJO associated with any given table. The table should contain at least one additional column that is not defined in the POJO.
  2. Attempt to call client.insert(...) for one of these POJO instances.
  3. Receive an IllegalArgumentException (No serializer found for column 'example'. Did you forget to register it?).

From my understanding, the problem comes from the fact that client.insert(...) assumes the resulting INSERT command should include values for all existing columns (which should not be the case), throwing an exception in line 1350 of com.clickhouse.client.api.Client when this is not the case.

Expected behaviour

client.insert(...) should ideally work even if the registered class is 'missing' some columns from the mapped table. While this can be partially solved by just adding said missing column into the registered class, this particular behavior can be problematic in certain cases

For example, when adding a new column to an existing table, this would theoretically break the mapping of the version running in production - which would not have the corresponding attribute in the POJO class.

Error log

java.lang.IllegalArgumentException: No serializer found for column 'example'. Did you forget to register it?	at com.clickhouse.client.api.Client.insert(Client.java:1350) 

Thanks in advance for reading this!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions