使用Postgres 14.5(和jOOQ 3.17.6),假设以下options
表定义:
CREATE TABLE options (
letter uuid NOT NULL,
is_selected bool NULL,
);
...with data:
| letter | is_selected |
| A | (null) |
| B | (null) |
| C | (null) |
| ... | (null) |
如何编写一个更新来指示选择了B
而其他值没有被选择?
我尝试了几件事:
jooq
.update(OPTIONS)
.set(OPTIONS.IS_SELECTED, OPTIONS.LETTER == val("B")) <-- this didn't work because I
think this a memory address
comparison
.set(OPTIONS.IS_SELECTED, OPTIONS.LETTER.equal(val("B"))) <-- this doesn't compile
.execute()
1条答案
按热度按时间2guxujil1#
从jOOQ 3.17和#11969开始,假设你的
BOOL
列实际上是一个BOOLEAN
,这可以很好地编译:原因是,对于#11969,
Condition
现在是Field<Boolean>
的子类型,这是这里所期望的。See also this section of the manual about boolean columns