fix sql for generator