我有一张player
号桌,上面有下面的DDL.我只更改了列名和顺序:
create table if not exists player (
id varchar primary key,
col1 boolean not null default false,
col2 json not null default '{}',
col3 varchar not null,
col4 varchar not null,
col5 json not null default '{}',
col6 boolean not null default false
);
下面是我try 运行的查询:
insert into player(id, col1, col2)
values (val_id, val1, val2)
on conflict(id)
do update set col1=excluded.col1, col2=excluded.col2
(存在具有相同id
的另一行,因此应该出现UPDATE
.)
col3
有一个NOT NULL
约束.(我在查询之前验证了它有值.)然而,当查询运行时,Postgres告诉我:
错误:...关系"Player"的列"col3"中的空值违反非空约束
当我给col3
设置一个缺省值时,没有出现错误,所有的值都是应该的.但我不需要缺省值.
我判断了Postgres文档,但找不到查询的错误.有什么问题吗?