fix an error in the generated sql