jdbi icon indicating copy to clipboard operation
jdbi copied to clipboard

Map kotlin.Pair

Open buremba opened this issue 6 years ago • 7 comments

It looks like Pair doesn't work with JDBI, it would be great if we could support it via rs.getObject(Int)

buremba avatar May 16 '18 00:05 buremba

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 avatar May 16 '18 01:05 qualidafial

@qualidafial, yes as a RowMapper. I thought that KotlinMapper should support that but it seems to support only data class.

buremba avatar May 16 '18 01:05 buremba

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.

qualidafial avatar Jun 01 '18 16:06 qualidafial

have our hands full just keeping up with the volume of PRs

sorry :p

leaumar avatar Jun 04 '18 22:06 leaumar

@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).

FredDeschenes avatar Aug 30 '18 17:08 FredDeschenes

@qualidafial are you still welcoming contributions on this?

msajawalsial avatar Feb 03 '24 19:02 msajawalsial

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 :)

stevenschlansker avatar Feb 05 '24 19:02 stevenschlansker