I want to get Row[N]<...>
representation of a generated JOOQ table type. I want to use it in this context:
val p = PROJECTS.`as`("p")
val pmu = PROJECTMEMBERUSERS.`as`("pmu")
val query = db
.select(p.asterisk(), DSL.arrayAgg(DSL.rowField(<-- insert Row[N]<...> here -->)))
.from(p.join(pmu).on(p.ID.eq(pmu.PROJECTID)))
.groupBy(p.ID)
I already tried inserting pmu.fieldsRow()
, but DSL.rowField(...)
expects another parameter type.
Error:(39, 58) Kotlin: None of the following functions can be called with the arguments supplied [...]
This question is a follow up question to Using PosgreSQL array_agg with join alias in JOOQ DSL but should be self contained.
Missing feature in jOOQ 3.11
There seems to be a missing feature in the jOOQ code generator, a generated
Table.fieldsRow()
overridden method that provides a more narrow, covariantRow[N]<...>
return type. I've created a feature request for this, to be implemented in jOOQ 3.12: https://github.com/jOOQ/jOOQ/issues/7809Also missing, an overloaded
DSL.rowField(RowN)
method: https://github.com/jOOQ/jOOQ/issues/7810Workaround, list columns explicitly
This is the most obvious workaround, which you obviously want to avoid: Listing all the column names explicitly:
Workaround, use generated records
There already is such a generated method in generated records. As a workaround, you could use
Workaround, extend the code generator
You can implement #7809 yourself already now, by extending the
JavaGenerator
with a custom code section:https://www.jooq.org/doc/latest/manual/code-generation/codegen-custom-code