Skip to content

Decouple Filter Classes #27

Description

@borhanst

Parent

#16 — Database Backend Abstraction for Multi-ORM Support

What to build

Update Filter ABC and all subclasses in filters/base.py to accept QueryBackend instead of raw SQLAlchemy query objects.

Changes:

  • Filter.apply(query, value)query parameter type changes from Any (SQLAlchemy select) to QueryBackend
  • Remove query.column_descriptions[0]["entity"] pattern — filters should receive the model reference separately or via the query adapter
  • TextFilter, BooleanFilter, RelationFilter, EnumFilter: use query.where(col == value) via query adapter
  • NumericFilter, DateRangeFilter, DatetimeRangeFilter: use query.where(col >= val) via query adapter
  • AutocompleteFilter: use query.where(col == value) via query adapter
  • get_choices(session)session parameter type changes to SessionBackend

Update DefaultQueryProvider._get_filter_choices() to pass SessionBackend to filter choices.

Acceptance criteria

  • Filter.apply() accepts QueryBackend as first parameter
  • All 7 filter subclasses updated to use query adapter methods
  • get_choices() accepts SessionBackend
  • Zero direct SQLAlchemy imports in filters/base.py
  • All existing filter tests pass

Blocked by

#25 (Query Adapter)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions