【发布时间】:2021-11-20 21:15:42
【问题描述】:
从 3.14 -> 3.15.3 升级我的 jOOQ 版本后弹出以下运行时错误:
ERROR: column "old_values" is of type jsonb but expression is of type character varying
代码如下:
final String jsonChanges = gson.toJson(map);
final InsertOnDuplicateStep<TicketLogRecord> insertLogs =
insertInto(LOG,
LOG.ID,
LOG.OLD_VERSION,
LOG.OLD_VALUES,
LOG.NEW_VALUES)
.select(
select(field("to_update.id", UUID.class),
field("to_update.version", Integer.class),
val("{}", JsonElement.class),
val(jsonChanges, JsonElement.class),
)
final var countUpdated =
with("to_update", "id", "version", "state_id").as(ids)
.with("update_states").as(updateWhere.returning())
.with("insert_logs").as(insertLogs.returning())
.select(count().as("updated_count"))
.from("to_update");
return using(configuration)
.fetchOne(countUpdated)
.getValue("updated_count", Integer.class);
通过强制转换cast(val("{}", JsonElement.class), LOG.OLD_VALUES) 并在其下方的行上同样使用 NEW_VALUES 解决了该问题。但我很感兴趣,为什么在这两个次要版本之间会出现这个 SQL 生成问题?
谢谢
【问题讨论】:
标签: jooq