jdbi
jdbi copied to clipboard
Map kotlin.Pair
It looks like Pair
doesn't work with JDBI, it would be great if we could support it via rs.getObject(Int)
Do you mean you want to map rows into Pair<A, B>
for arbitrary mappable A
and B
? I think we could reasonably support that (although not through rs.getObject(int)
, as it is defined in the JDK and we have no control over it).
We already do something similar with Map.Entry<K,V>
. See http://jdbi.org/#_map_entry_mapping
We also support mapping to Vavr Tuple2
.
@qualidafial, yes as a RowMapper
. I thought that KotlinMapper
should support that but it seems to support only data class
.
FYI: there probably won't be progress on this unless you or somebody else submits a PR. None of the project members (that I'm aware of) code in Kotlin, and we rather have our hands full just keeping up with the volume of PRs since 3.0 was released.
have our hands full just keeping up with the volume of PRs
sorry :p
@buremba : As a quick workaround, you could use the Map.Entry
mapper mentioned above and do .map { it.toPair() }
(the toPair
extension method is added to the Map.Entry
class via Kotlin's stdlib).
@qualidafial are you still welcoming contributions on this?
If this feature is important to you, please consider contributing a fix! We always welcome well thought out contributions. Extra points are awarded for improving the documentation and having good tests :)