FilterSet#
Reusable filter definitions combine typed field parameters, relationship predicates, sorting, and inferred eager loading. See Declarative Filters for examples and matching semantics.
- class advanced_alchemy.filters.FilterSet(
- *,
- cursor_defaults=None,
- require_cursor_secret=False,
- **values,
Bases:
StatementFilter,Generic[ModelT]Reusable typed filters for one mapped model.
Declare
filter_fieldswith dotted model paths and instantiate with typed double-underscore parameters, such asorders__price__ge=10. Different fields match independently; operators on one field share a related row. Framework providers validate HTTP values before constructing this object.- Parameters:
cursor_defaults (CursorDefaults | None) – Application-wide cursor token options, used where the configuration sets none.
require_cursor_secret (bool) – Refuse to issue or accept unsigned cursor tokens.
**values (Any) – Typed field values and configured pagination, ordering or search values.
- Raises:
ValueError – An unknown query parameter is supplied.
ImproperConfigurationError – The model, declared fields, or cursor options are invalid.
- to_statement_filters()#
Return the compiled primitive filters for explicit query integration.
- Returns:
A fresh list of native filters and custom SQL expressions.
- Return type:
list[StatementFilter | ColumnElement[bool]]
- inferred_load(dialect=None)#
Infer loading options for active relationship paths.
- Parameters:
dialect (Any) – Optional SQLAlchemy dialect, used for composite-key SQL Server loading.
- Returns:
Joined to-one, select-in collection, or composite SQL Server subquery options.
- Return type:
list[ExecutableOption]