I have two functions: one returns a list of fields, the other returns a select query (which selects the corresponding values of the fields).
private List<Field<?>> fields() {
....
}
private Select<?> select() {
...
}
Note that the degree is determined at runtime, it depends on the user input. Hence List<Field<?>>
and Select<?>
.
It is possible to insert into a table:
context.insertInto(table, fields()).select(select()))
It is not possible to update a table:
context.update(table).set(DSL.row(fields()), select())
Could this functionality be added to jOOQ 3.7?
Which workaround can we use for now?
Nice catch, there's a missing method on the
UpdateSetFirstStep
DSL API, which acceptsRowN
as a first argument, the type returned fromDSL.row(Collection)
. This should be fixed for jOOQ 3.7: https://github.com/jOOQ/jOOQ/issues/4475As a workaround, and if you can live with the guilt of the hack, you could cast to raw types:
You can cast
DSL.row(fields())
toRow1
, because the internal implementation type returned byDSL.row(fields())
implements allRow[N]
types.