Move most of BaseQuery into FlaskQueryMixin.