Fixed some bugs in DAO.stg/custom_selects.stg. refs #500