fix minor bugs in form -> sql