Skip to content

Commit

Permalink
docs: write NullFilterMap.visit_statement docstring
Browse files Browse the repository at this point in the history
Refs #10
  • Loading branch information
Aesonus committed Oct 19, 2024
1 parent 0e2293c commit b48942d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions alchemical_storage/filter/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,21 @@ def __init__(
self.filters[filter_] = get_by

def visit_statement(self, statement: T, params: dict[str, Any]) -> T:
"""Apply filters to an ``sqlalchemy.Select`` instance. Each key in ``params``
corresponds to a filter configured in the constructor. If the ``params`` key is
not configured, it is ignored.
Arguments:
statement: The ``sqlalchemy.Select`` instance to apply ``where`` filters to
params: The filters and their parameters to apply
Returns:
The new ``sqlalchemy.Select`` instance with the filters applied
Raises:
NullFilterException: If an unknown filter value is encountered
"""
return statement.where(*self._generate_where_clauses(params))

def _generate_where_clauses(self, given_filters: dict[str, Any]):
Expand Down

0 comments on commit b48942d

Please sign in to comment.