-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Milestone
Description
Expected behavior
We have our application running in jooq 3.17.4 and we want to bump jooq to 3.18.4 (and after in 3.19.x) but we encounter some issues.
When we use jooq to generate query like :
SELECT "mcve"."test"."code", "mcve"."test"."parent_code"
FROM "mcve"."test"
WHERE "mcve"."test"."code" <> 'value' AND
('value' = ANY ("mcve"."test"."parent_code") OR "mcve"."test"."code" = ANY (ARRAY [(SELECT "mcve"."test"."parent_code" FROM "mcve"."test" WHERE "mcve"."test"."code" = 'value')]))
;Our current code looks like
Condition condition = includeRoot ? trueCondition() : TEST.CODE.ne("");
if (StringUtils.isNotEmpty(code)) {
condition = condition.and(
or(
// get children
value(code).equal(any(TEST.PARENT_CODE)),
// get parents
TEST.CODE.equal(any(array(select(TEST.PARENT_CODE)
.from(TEST)
.where(TEST.CODE.equal(code))
.asField())))
)
);
}
return ctx.select(TEST.CODE, TEST.PARENT_CODE)
.from(TEST)
.where(condition)
.fetch(TEST.CODE):See mcve for full example
Actual behavior
in jooq 3.18.7, application raise exception like
org.jooq.exception.DataAccessException: SQL [select "mcve"."test"."code", "mcve"."test"."parent_code" from "mcve"."test" where ("mcve"."test"."code" <> ? and (? = any ("mcve"."test"."parent_code") or "mcve"."test"."code" = (select "mcve"."test"."parent_code" from "mcve"."test" where "mcve"."test"."code" = ?)))]; ERROR: operator does not exist: character varying = character varying[]
Indice : No operator matches the given name and argument types. You might need to add explicit type casts.
Position : 179
we can see the current request is not well generated
Steps to reproduce the problem
https://github.com/Bzil/jOOQ-mcve/tree/main/jOOQ-mcve-java-postgres
jOOQ Version
3.18.7
Database product and version
PostgreSQL 12.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
Java Version
openjdk 21.0.1 2023-10-17 LTS OpenJDK Runtime Environment Zulu21.30+15-CA (build 21.0.1+12-LTS) OpenJDK 64-Bit Server VM Zulu21.30+15-CA (build 21.0.1+12-LTS, mixed mode, sharing)
OS Version
No response
JDBC driver name and version (include name if unofficial driver)
org.postgresql:postgresql:42.6.0