There is a constraint violation handling "On conflict" statement, working fine if i want to check 1 (!) constraint
For example :
INSERT INTO my_table (co1,col2..colN)
VALUES (...)
ON CONFLICT (col1, col2) DO NOTHING --or update
But if i have 2 constaints unique(col1,col2) and unique(col5,col6,col7) , the query below is not working :
INSERT INTO my_table (co1,col2..colN)
VALUES (...)
ON CONFLICT (col1, col2) DO NOTHING --or update
ON CONFLICT (col5, col6, col7) DO NOTHING --or update
This raises the error, pointing on : ERROR: syntax error at or near "on". LINE _: on conflict (col5, col6, col7) do nothing
How could i resolve using multiple constraint checking in one query?
ON CONFLICT DO NOTHING). In the general case (for instance doing nothing on 2 out of 3 constrains, or on 1 do nothing and the other one do an update), you would need to be able to know at planning-time whether those conflict or not (eg do you update or do you ignore). This, as far as I know, is not implemented (nor planned to be).try: query; except IntegrityError: rollback, but seems this is bad solution, and there is probably sql way without usingconflictstatement, if conflict statement cannot resolve multiple constraint handling