I did this to solve the problem regarding having null values in 2 columns for a unique constraint in PostgreSQL:
CREATE UNIQUE INDEX uc_column1_column2_column3_column4 ON schema.table
(column1, column2, COALESCE(column3, '0'), COALESCE(column4,'0'));
See here: Create unique constraint with null columns
But now I have an other problem because using index instead of constraint I have the error:
there is no unique or exclusion constraint matching the ON CONFLICT specification
when I do this SQL request:
INSERT INTO table
(column1,column2, column3, column4, columnA, columnB, columnC)
VALUES (1,2,3,4,A,B,C)
ON CONFLICT (column1,column2, column3, column4)
DO UPDATE SET column1= EXCLUDED.column1
RETURNING *
Note: I do get the correct constraint error without the "on conflict" line.