Skip to content

Filter methods  #540

@foarsitter

Description

@foarsitter

When I'm filtering on an amount I want to include null values. This involves an or_.

I modified the filter method so it checks if there is a filter method defined, i.e:

class ProductFilter(Filter):
    costs__lte: int | None = Field(None)

    def filter_costs__lte(self, value: Any, query: Union[Query, Select]) -> Union[Query, Select]:
        return query.filter(
            or_(
                Product.costs <= value,
                Product.costs == null()
            )
        )

I can provide a PR when this is the way you want to go.

Thanks for providing this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions