work around bug in mysql 5.1 when upserting