eclipse-vertx / eclipse-vertx/vertx-sql-client

Introduce SPI Row/Tuple converter

Open
#1,013 8 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
912
Forks
212
Avg merge
17h 30m
Merged PRs (30d)
3

Description

#### Describe the feature

Add new convention method for `Row` to accept `converter`.
Introduce 2 converter interfaces, it should be 2-way converter: `JDBC`/`Reactive SQL` <=> User data type.
- `DataTypeConverter` for converting by data type
- `ColumnConverter` for converting by data type and column name

Something like that
```java
interface Row {
default T get(String column, ColumnConverter converter) {
return converter.convert(getValue(column));
}
}
```

Then extract every `get` to `Converter`, then add them to `SPI` as Vertx convention.
On each database driver/business model, developer can easy enhance or override default converter and make seamlessly UDT from database to java type

The concept will be similar on what I have done in [jooqx](https://github.com/zero88/jooqx) such as:
https://github.com/zero88/jooqx/blob/fcc473908cdbcc7b61544ccfbc97b4f7a8797b13/core/src/main/java/io/zero88/jooqx/datatype/JooqxConverter.java#L19
and
https://github.com/zero88/jooqx/blob/fcc473908cdbcc7b61544ccfbc97b4f7a8797b13/core/src/main/java/io/zero88/jooqx/datatype/DataTypeMapperRegistry.java#L23

#### Contribute
I might take it if you want to minimum API change in my lib also.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.