Hi Max,

Thanks for your message. Indeed, it would be handy - I don't deny that at
all. The problem with jOOQ's current API is that we cannot implement this
without breaking the API. Or, we could use a dummy name instead of unnest -
so we don't have to touch the existing API. The existing API reads:

Table<?> unnest(Field<?>)


Notice 1) it returns a Table, 2) We don't have any <T> type information.

Note also that you can always work around this limitation easily by writing:

public static Field<T> myUnnest(Field<? extends T[]> array) {

    return DSL.field("unnest({0})", (Class<T>)
array.getType().getComponentType(), array);

}


In any case, I'm curious about your "universal" unnesting use-case. This is
probably only a good idea if you have at most one array column, because
unnest creates a cartesian product between the row and the array(s). Would
you mind explaining your use-case a bit more? Perhaps we can find an
entirely different solution to this...

Best Regards,
Lukas

2017-02-15 22:37 GMT+01:00 Max Kremer <mkre...@trialfire.com>:

> Hi,
>
>   I'd like to revive this thread if I may.
>
> I think it would be really handy to have DSL.unnest work as described by
> Julian even tho it is syntactic sugar for later join.
>
> Here's why. Lets say you're building the queries dynamically in jooq by
> mapping a set of fields in your domain model to jooq Field<>.
> When a field is of type array and you  know you're going to unnest it
> universally then why make me muck about with my join and from clauses?
>
> For example
>
> class Foo {
> ..
>    Field<?> convertToJooqField() {
> }
>
> ArrayList<Foo> foos;
>
> I want to be able to build my select list by mapping over foos and
>
> d.select(foos.map( f - f->convertToJooqField))
>
> if the convertToJooqField has some logic that wraps a tags field for
> example with an UNNEST the above would brake.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jooq-user+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to