News for hackers. Stuff that matters.
Re:Postgres gets support for upsert by ryan0x00 on Friday May 08, 2015 @12:15AM (#9509935)
i've seen a system in mysql do "insert on duplicate key update" for ages, so this is that same pattern?
Re:Postgres gets support for upsert by girvo on Friday May 08, 2015 @12:22AM (#9509949)
Yeah, it is the same as INSERT ... ON DUPLICATE KEY UPDATE, and similar to REPLACE in MySQL. Exciting to see it in Postgres!
Re:Postgres gets support for upsert by kkland on Friday May 08, 2015 @01:33PM (#9513013)
I think the way MySQL works in doing "INSERT ... ON DUPLICATE KEY UPDATE" is to delete the old row and insert a new row if there's an auto incremental column (mostly it's ID column). Being curious if Postgres works the same way in this regard.
Re:Postgres gets support for upsert by girvo on Saturday May 09, 2015 @03:17AM (#9515774)
No, that's how REPLACE works -- which is a complete pain to be honest! INSERT ... UPDATE works the way you'd hope it would, and keeps the auto inc columns correct.
Re:Postgres gets support for upsert by dugmartin on Friday May 08, 2015 @02:46PM (#9513439)
No, the auto increment columns are maintained as is.
Re:Postgres gets support for upsert by kkland on Friday May 08, 2015 @05:38PM (#9514283)
That's great. Otherwise, it just wastes IDs unless one figures out a workaround for it.