CREATEUNIQUE INDEX IF NOTEXISTS uniq_id_test ON test USING btree (type, id) WHERE (type ='Test');
PREPARE test (text, int, text) ASINSERTINTO test (type, id) VALUES ($1, $2) ON CONFLICT (type, id) WHERE type = $3 DO UPDATESET id = EXCLUDED.id;
EXECUTE test('Test', 6, 'Test');
The last EXECUTE statement always throws an error:
[42P10] ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
All of it works fine if we replace $3 parameter with a constant value 'Test' (no errors):
PREPARE test (text, int, text) ASINSERTINTO test (type, id) VALUES ($1, $2) ON CONFLICT (type, id) WHERE type ='Test' DO UPDATESET id = EXCLUDED.id;
This is a known deficiency that the first query ever works at all. It should error every time.