refactor for SelectWriter::writeSelectHaving