How to use RETURNING with ON CONFLICT in PostgreSQL?

I have the following UPSERT in PostgreSQL 9.5: INSERT INTO chats (“user”, “contact”, “name”) VALUES ($1, $2, $3), ($2, $1, NULL) ON CONFLICT(“user”, “contact”) DO NOTHING RETURNING id; If there are no conflicts it returns something like this: ———- | id | ———- 1 | 50 | ———- 2 | 51 | ———- But if … Read more