From 26aa46209e2f397945a1d54cc1709af8e962b750 Mon Sep 17 00:00:00 2001 From: slymit Date: Thu, 13 Jun 2024 20:52:41 +0300 Subject: [PATCH] Rename the param 'query' to 'stmt' in functions apply_filters, apply_loads and apply_sort --- sa_filters/filters.py | 14 +++++++------- sa_filters/loads.py | 14 +++++++------- sa_filters/sorting.py | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sa_filters/filters.py b/sa_filters/filters.py index d74f855..5639d1e 100644 --- a/sa_filters/filters.py +++ b/sa_filters/filters.py @@ -202,13 +202,13 @@ def get_named_models(filters): def apply_filters( - query: Union[Select, Query], + stmt: Union[Select, Query], filter_spec: Union[Iterable[Dict[str, Any]], Dict[str, Any]], do_auto_join: bool = True ) -> Union[Select, Query]: """Apply filters to a SQLAlchemy query or Select object. - :param query: + :param stmt: The statement to be processed. May be one of: a :class:`sqlalchemy.sql.Select` object or a :class:`sqlalchemy.orm.Query` object. @@ -248,18 +248,18 @@ def apply_filters( """ filters = build_filters(filter_spec) - default_model = get_default_model(query) + default_model = get_default_model(stmt) filter_models = get_named_models(filters) if do_auto_join: - query = auto_join(query, *filter_models) + stmt = auto_join(stmt, *filter_models) sqlalchemy_filters = [ - filter.format_for_sqlalchemy(query, default_model) + filter.format_for_sqlalchemy(stmt, default_model) for filter in filters ] if sqlalchemy_filters: - query = query.filter(*sqlalchemy_filters) + stmt = stmt.filter(*sqlalchemy_filters) - return query + return stmt diff --git a/sa_filters/loads.py b/sa_filters/loads.py index 9abf857..51ac05e 100644 --- a/sa_filters/loads.py +++ b/sa_filters/loads.py @@ -48,13 +48,13 @@ def get_named_models(loads): def apply_loads( - query: Union[Select, Query], + stmt: Union[Select, Query], load_spec: Union[List[Dict[str, Any]], Dict[str, Any], List[str]] ) -> Union[Select, Query]: """Apply load restrictions to a :class:`sqlalchemy.sql.Select` object or a :class:`sqlalchemy.orm.Query` object. - :param query: + :param stmt: The statement to be processed. :param load_spec: @@ -90,15 +90,15 @@ def apply_loads( loads = [LoadOnly(item) for item in load_spec] - default_model = get_default_model(query) + default_model = get_default_model(stmt) load_models = get_named_models(loads) - query = auto_join(query, *load_models) + stmt = auto_join(stmt, *load_models) sqlalchemy_loads = [ - load.format_for_sqlalchemy(query, default_model) for load in loads + load.format_for_sqlalchemy(stmt, default_model) for load in loads ] if sqlalchemy_loads: - query = query.options(*sqlalchemy_loads) + stmt = stmt.options(*sqlalchemy_loads) - return query + return stmt diff --git a/sa_filters/sorting.py b/sa_filters/sorting.py index 2bf2a16..056b29f 100644 --- a/sa_filters/sorting.py +++ b/sa_filters/sorting.py @@ -73,13 +73,13 @@ def get_named_models(sorts): def apply_sort( - query: Union[Select, Query], + stmt: Union[Select, Query], sort_spec: Union[List[Dict[str, Any]], Dict[str, Any]] ) -> Union[Select, Query]: """Apply sorting to a SQLAlchemy :class:`sqlalchemy.sql.Select` object or a :class:`sqlalchemy.orm.Query` object. - :param query: + :param stmt: The statement to be processed. :param sort_spec: @@ -118,16 +118,16 @@ def apply_sort( sorts = [Sort(item) for item in sort_spec] - default_model = get_default_model(query) + default_model = get_default_model(stmt) sort_models = get_named_models(sorts) - query = auto_join(query, *sort_models) + stmt = auto_join(stmt, *sort_models) sqlalchemy_sorts = [ - sort.format_for_sqlalchemy(query, default_model) for sort in sorts + sort.format_for_sqlalchemy(stmt, default_model) for sort in sorts ] if sqlalchemy_sorts: - query = query.order_by(*sqlalchemy_sorts) + stmt = stmt.order_by(*sqlalchemy_sorts) - return query + return stmt