I have request that is a very similar to this problem postgresql ON CONFLICT with multiple constraints with only difference that I need to do DO UPDATE instead of DO NOTHING
CREATE TABLE test_table (
col1 INTEGER,
col2 INTEGER,
col3 INTEGER,
col4 INTEGER,
CONSTRAINT col1_col2_unq UNIQUE (col1, col2),
CONSTRAINT col1_col3_unq UNIQUE (col1, col3)
);
Is there any way to do something like this:
INSERT INTO test_table (col1,col2,col3,col4) values
(?,?,?,?)
ON CONFLICT ON CONSTRAINT (col1_col2_unq OR col1_col3_unq)
DO UPDATE set col1 = EXCLUDED.col1
Now ON CONFLICT accepts only 1 unique constrain. Is there any options how to perfrom validataion for two set of unique fields before insert and update row if it matches any of them?