2015-06-05 10:42 GMT+02:00 Ben Hood <[email protected]>:

> Hi Lukas,
>
> I was wondering how you write LEFT JOIN LATERAL (...) ON true using the
> DSL.
>

Depending on the contents of LATERAL (...) you might just use CROSS JOIN
LATERAL (...) instead, which can work the same way...


> To build the following query:
>
> SELECT
>     choice,
>     entry_announcements.id,
>     entry_announcements.encoding,
>     number
> FROM
>     ivr_menus
> LEFT OUTER JOIN
>     ivr_announcements
> ON
>     ivr_menus.plan = ivr_announcements.plan
> LEFT OUTER JOIN
>     entry_announcements
> ON
>     entry_announcements.id = ivr_announcements.announcement_id
> JOIN
>     group_assignments
> ON
>     group_assignments.group_id = ivr_menus.group_id
>
> LEFT JOIN LATERAL
> (
>         SELECT
>             entry_announcements.id,
>             entry_announcements.encoding
>         FROM
>             entry_announcements
>         JOIN
>             pre_canned_announcements
>         ON
>             pre_canned_announcements.announcement_id =
> entry_announcements.id
>         LIMIT 1) "pre_canned" ON true
>
> WHERE
>     ivr_menus.plan = 1
> ORDER BY
>     ivr_announcements.announcement_id DESC;
>
> I've got the following building blocks:
>
> Table preCanned =
>     DSL.select().
>         from(ENTRY_ANNOUNCEMENTS).
>         join(PRE_CANNED_ANNOUNCEMENTS).
>           on(PRE_CANNED_ANNOUNCEMENTS.ANNOUNCEMENT_ID.eq(
> ENTRY_ANNOUNCEMENTS.ID)).
>         limit(1).
>         asTable("pre_canned");
>
> and then when constructing the "LEFT JOIN LATERAL (...) ON TRUE" I'm
> trying the following fragment
>
> .leftOuterJoin(DSL.lateral(
>     preCanned
> )).on(true).
>
> But the compiler is not down with
>
> on(boolean)
>
> Am I doing something wrong here?


We could provide an on(Boolean) overload (and where(Boolean),
having(Boolean), etc.). It wouldn't be too inconsistent with existing API,
given that we already have on(Field<Boolean>). I have registered a feature
request for this:
https://github.com/jOOQ/jOOQ/issues/4366

In the meantime, you'll have to somehow generate a "true" predicate. Here
are some ideas:

on("true")
on("1 = 1")
on(DSL.trueCondition())
on(DSL.condition(true))
...

Hope this helps,
Lukas

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to