Fix sql on update