Your INSERT only provides a value for the full_payload
column, but not the payload
column. However the payload
column is defined as not null
so the INSERT (not the UPDATE) fails because of that. You have to provide a non-null value for the column payload
in your INSERT statement.
You can also remove the unnecessary updates to the current value in the UPDATE part, they serve no purpose. I would rather expect that last_updated
should be set to the current timestamp.
So something like:
INSERT INTO sample AS t (identifier, full_payload, payload)
VALUES ('12345','{"a":"b"}', '{}')
ON CONFLICT ON CONSTRAINT sample_pkey
DO UPDATE
SET full_payload = EXCLUDED.full_payload,
last_updated = current_timestamp;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…