BUG #16706: insert into on conflict(pk) do update error violates not-null constraint

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Дата
Msg-id 16706-08837c0cdaf4ce57@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16706
Logged by:          zhongxuchen
Email address:      zhongxuchen@gmail.com
PostgreSQL version: 12.3
Operating system:   centos8
Description:

1、mysql/postgresql saveOrUpdate或saveOrUpdateAll操作时的on conflict () do update
当某个字段在数据库中设置为not null,SQL 错误 [23502]: ERROR: null value in column "name"
violates not-null constraint

example:
CREATE TABLE TEST1 (
    id varchar(100) NOT NULL,
    name varchar(100) NOT NULL,
    status varchar(100) NOT NULL,
    CONSTRAINT test1_pkey PRIMARY KEY (id)
)

insert into TEST1 (ID, NAME,STATUS ) values('4','test','6') ;
insert into TEST1 as t1 (ID, NAME,STATUS ) values('4',null,'6') on conflict
(id) do update set NAME=COALESCE(excluded.NAME,t1.NAME),
STATUS=COALESCE(excluded.STATUS,t1.STATUS);


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Dilip Kumar
Дата:
Сообщение: Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop