move sql builder out of active record.