Fix generation of update sql