关于the PostgreSQL documentation有一个关于如何更新复合类型的子字段的示例:
We can update an individual subfield of a composite column:
UPDATE mytab SET complex_col.r = (complex_col).r + 1 WHERE ...;
假设我们使用 jOOQ 和代码生成,这将如何转换为 jOOQ 代码?
最佳答案
从 jOOQ 3.15 开始,还没有允许访问 UDT 成员的 API:https://github.com/jOOQ/jOOQ/issues/228
与往常一样,您可以使用 plain SQL templating 轻松解决此缺失的功能。 :
Field<Integer> r = field("({0}).{1}", COMPLEX_TYPE.R.getDataType(),
MYTAB.COMPLEX_COL.getUnqualifiedName(),
COMPLEX_TYPE.R.getUnqualifiedName()
);
ctx.update(MYTAB)
.set(r, r.plus(1))
.where(...)
.execute();
关于postgresql - 如何使用 jOOQ 更新 PostgreSQL 上复合列的单个子字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69836099/