Hi there, jOOQ is very opinionated in this area.
You may think that comparing ints and longs is still ok-ish. But what about comparing Strings and ints? Or Strings and dates? Dates and booleans? Where do you draw the line? And how would that be expressed using a generic API in Java? As this is not something that happens very often, jOOQ can safely assume that by default, either you have a mistake in your schema, in case of which you need to cast() (affects generated SQL) or coerce() (doesn't affect generated SQL), or, more likely, in your query. So, this compilation error is a very good thing in 99% of the cases. Do note that even if your comparison makes sense in this particular case, implicit type conversion in SQL is a can of worms in terms of performance. It often prevents using appropriate indexes. If you cannot fix your schema, you can use <forcedTypes/> in your code generator to produce a BIGINT type for your INTVAL column. I hope this helps Lukas On Wed, Nov 7, 2018 at 11:56 AM <[email protected]> wrote: > Hi! > I work in Postgres. Let's say we have tables t1 with "int8" column > "longVal" and table t2 with "int4" column "intVal". In Postges > t1.longVal = t2.intVal > is possigle, but JOOQ requires casting > t1.LONGVAL.eq(t2.INTVAL.cast(SQLDataType.BIGINT)) > otherwise it won't even compile. > > t1.LONGVAL is TableField<t1Record, Long> > t2.INTVAL is TableField<t2Record, Integer> > > Why JOOQ requires casting if SQL doesn't? > > Is it possible to write this comparison without casting, so there would be > no CAST in generated SQL querry? > > -- > 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.
