fastapi-filter icon indicating copy to clipboard operation
fastapi-filter copied to clipboard

Filter relations by search_model_fields

Open christianramcke opened this issue 3 years ago • 7 comments

Is there a way to filter relation fields by search_model_fields in Filter.Constants?

For example:

class OrderFilter(Filter):
    search: Optional[str]
    order_id: Optional[int]
    description: Optional[str]
    address: Optional[AddressFilter] = FilterDepends(with_prefix("address", AddressFilter))

    class Constants(Filter.Constants):
        model = Order
        search_field_name = "search"
        search_model_fields = ["order_id", "description", "address.last_name"]

I want to add a field of the address relation in search_model_fields - address.last_name in this case.

I use SQLAlchemy as ORM.

Thank you alot for this fine piece of software <3

christianramcke avatar Jan 04 '23 21:01 christianramcke

I think it shouldn't be too hard 🤔 I'll kick off a PR 👍🏻

arthurio avatar Jan 11 '23 05:01 arthurio

Hi, @arthurio

When is this feature supposed to come? It's a very functional feature. ❤️

mertcangokgoz avatar Mar 26 '23 23:03 mertcangokgoz

@mertcangokgoz I have been busy, sorry for things slowing down a bit... I'll pick this up this week!

arthurio avatar Mar 30 '23 01:03 arthurio

@mertcangokgoz I have been busy, sorry for things slowing down a bit... I'll pick this up this week!

Any update @arthurio

mertcangokgoz avatar Jul 18 '23 10:07 mertcangokgoz

Before starting to work on the few "feature" PRs I had opened I started to restructure the documentation a notch https://github.com/arthurio/fastapi-filter/pull/375. Unfortunately this is still in progress but I might go back to doing the features first in order to have a "clean" plate to take on pydantic v2 support.

arthurio avatar Jul 18 '23 10:07 arthurio

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jan 06 '24 05:01 github-actions[bot]

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.

github-actions[bot] avatar Mar 07 '24 01:03 github-actions[bot]

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.

github-actions[bot] avatar May 07 '24 01:05 github-actions[bot]