-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a <T, E> Field<Result<R>>.collecting(Collector<R, ?, E>) kotlin extension function, and similar #13538
Milestone
Comments
This is truly fantastic!! Here's the compilation test case: @Test
fun testMultisetMapping() {
data class C1(val i1: Int?)
data class C2(val i1: Int?, val i2: Int?)
data class C3(val i1: Int?, val i2: Int?, val i3: Int?)
var s1: Select<Record1<List<C1>>> = select(multiset(select(i)).mapping(::C1))
var s2: Select<Record1<List<C2>>> = select(multiset(select(i, j)).mapping(::C2))
var s3: Select<Record1<List<C3>>> = select(multiset(select(i, j, k)).mapping(::C3))
var ca1: Select<Record1<Array<Int>>> = select(multiset(select(i)).intoArray())
var ca2: Select<Record1<Array<String>>> = select(multiset(select(i)).intoArray { it.toString() })
var cl1: Select<Record1<List<Int>>> = select(multiset(select(i)).intoList())
var cl2: Select<Record1<List<String>>> = select(multiset(select(i)).intoList { it.toString() })
var cs1: Select<Record1<Set<Int>>> = select(multiset(select(i)).intoSet())
var cs2: Select<Record1<Set<String>>> = select(multiset(select(i)).intoSet { it.toString() })
var cm1: Select<Record1<Map<Int, Int>>> = select(multiset(select(i, j)).intoMap())
var cm2: Select<Record1<Map<String, Record2<Int, Int>>>> = select(multiset(select(i, j)).intoMap { it.toString() })
var cm3: Select<Record1<Map<String, String>>> = select(multiset(select(i, j)).intoMap({ it.toString() }, { it.toString() }))
var cg1: Select<Record1<Map<Int, List<Int>>>> = select(multiset(select(i, j)).intoGroups())
var cg2: Select<Record1<Map<String, List<Record2<Int, Int>>>>> = select(multiset(select(i, j)).intoGroups { it.toString() })
var cg3: Select<Record1<Map<String, List<String>>>> = select(multiset(select(i, j)).intoGroups({ it.toString() }, { it.toString() }))
} |
lukaseder
changed the title
Add a <T, E> Field<Result<R>>.collecting(Collector<R, ?, E>) kotlin extension function
Add a <T, E> Field<Result<R>>.collecting(Collector<R, ?, E>) kotlin extension function, and similar
May 9, 2022
lukaseder
added a commit
that referenced
this issue
May 9, 2022
… kotlin extension function, and similar
lukaseder
added a commit
to jOOQ/demo
that referenced
this issue
May 9, 2022
Possible alternative implementation directly in the Java API: #13539 |
Nice job! |
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jOOQ 3.17 is adding
<T[N], E> Field<Result<Record[N]>>.mapping(Function[N]<T[N], E>): Field<List<E>>
extension methods with #12945It would also be useful to add a few convenience shortcuts to the
Collector
types fromRecords
, via:<T, E> Field<Result<R>>.collecting(Collector<R, ?, E>): Field<E>
<K, V> Field<Result<Record2<K, V>>>.intoMap(): Field<Map<K, V>>
<K, V> Field<Result<Record2<K, V>>>.intoGroups(): Field<Map<K, List<V>>>
And a few others
The text was updated successfully, but these errors were encountered: