Strange translation of jOOQ query for array contains function Strange translation of jOOQ query for array contains function postgresql postgresql

Strange translation of jOOQ query for array contains function


jOOQ currently (as of version 3.8) does not recognise your custom data type as still being an array data type in PostgreSQL, which is why the Field.contains() default behaviour kicks in - i.e. the one that treats all values as strings.

I've created feature request #5602 for this. As a workaround, you might need to roll your own using plain SQL:

public static <T, C extends Collection<T>> Condition contains(    Field<? extends C> left,     C right) {    return DSL.condition("{0} @> {1}::text[]", left, DSL.val(right, left.getDataType()));}

... which you can then use as such:

contains(c.MYOPTIONS, Sets.newHashSet("option1"))


Please try following solution. Worked in my case.

select.where(ARRAY_FIELD.contains(DSL.cast(DSL.array(VALUE), ARRAY_FIELD.getDataType())));