"UPDATE table_name SET w = $1, x = $2, z = $4 WHERE y = $3 RETURNING *",

does not do the same as

"UPDATE table_name SET w = $1, x = $2, y = $3, z = $4 RETURNING *",

It’s 2 am and my mind blanked out the WHERE, and just wanted the numbers neatly in order of 1234.

idiot.

FML.

  • dbilitated@aussie.zone
    link
    fedilink
    arrow-up
    15
    ·
    1 year ago

    I did that once when I moved from one DB IDE to another and didn’t realise the new one only ran the highlighted part of the query.

    there were thousands of medical students going through a long process to find placements with doctors and we had a database and custom state machine to move them through the stages of application and approval.

    a bug meant a student had been moved to the wrong state. so I used a snippet of SQL to reset that one student, and as a nervous habit highlighted parts of the query as I reread them to be sure it was correct.

    then hit run with the first half highlighted, without the where clause, so everyone in the entire database got moved to the wrong fucking state.

    we had 24 hourly backups but I did it late in the evening, and because it was a couple of days before the hard deadline for the students to get their placements done hundreds of students had been updating information that day.

    I spent until 4am the next day working out ways to imply what state everyone was in by which other fields had been updated to what, and incidentally found the original bug in the process 😒

    anyway, I hope you feel better soon buddy. it sucks but it happens, and not just to you. good luck.