Hello Gabriel,

I'm very sorry for the delay. I've noticed that this E-Mail is still
unanswered!

You're right, I can reproduce the issue. The outermost cast does indeed set
a flag, which isn't reset again. We'll fix this ASAP. I have registered an
issue for this:
https://github.com/jOOQ/jOOQ/issues/4466

(A very late) thanks for reporting!
Lukas

2015-07-08 15:22 GMT+02:00 Gabriel Forró <[email protected]>:

> Hi,
>
> I would like to share a feature of JOOQ, which can lead to an invalid SQL
> in case of Postgres for example.
> The following code snippet will generate an invalid SQL:
>
> Jooq Java:
>
> java.sql.Date theDate = ...
> cast(dateAdd(value(theDate), inline(10)), Timestamp.class)
>
>
> Generated SQL:
> cast((? + (10 || ' day')::interval)::date as timestamp)
>
> The problem is caused by the missing cast of the bound parameter, which is
> a date. Without the explicit cast the date aritmethics (the dateAdd(...)
> function) will not work and the SQL will fail.
> Correct SQL is:
> cast((cast(? as date) + (10 || ' day')::interval)::date as timestamp)
>
> Reason of the problem:
> The context's CastMode is set to NEVER in the inner part of a cast, so
> there will be no nested casts (in the org.jooq.impl.Cast.Native class)
>
> --
> 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.
>

-- 
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