How to upsert non-null columns (PostgreSQL)

INSERT INTO user (id, name, randomStuff) VALUES (:P1, :P2, :P3) 
UPDATE SET name=:P2, randomStuff=:P3; -- How can I skip updating :P3 here if it's NULL?

I assume this always updates “randomStuff”, even if :P3 is NULL. How can I skip updating this column (randomStuff) if :P3 is NULL? I don’t want to overwrite something non-null with null.

Thanks for any advice!

Community Page
Last updated: