fix bug for sql