Avoid using rails to_query so we don't need active_record