From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: zhongxuchen@gmail.com
Subject: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Date: Mon, 09 Nov 2020 09:13:10 +0000
Message-ID: <16706-08837c0cdaf4ce57@postgresql.org> (raw)
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);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, zhongxuchen@gmail.com
Subject: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
In-Reply-To: <16706-08837c0cdaf4ce57@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox