You're exactly right!  Good catch, I had misremembered how this worked.  And so this was causing an insiduous bug as coded here, duplicate ExamRecord rows with primary keys were getting created since we never found a previous one.  Well done.  Pushing a fix now.