fastapi-filter
fastapi-filter copied to clipboard
Filter methods
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!
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.