igorbenav / fastcrud

FastCRUD is a Python package for FastAPI, offering robust async CRUD operations and flexible endpoint creation utilities.
MIT License
530 stars 32 forks source link

Missing sqlalchemy operators #85

Closed JakNowy closed 2 weeks ago

JakNowy commented 1 month ago

This implements #79 by introducing FastCRUD._get_sqlalchemy_filter() method and a dictonary of filter mappings in FastCRUD._SUPPORTED_FILTERS. Adding new sqlalchemy opertors is as simple as extending the dictonary.

It also solves the or_() operator issue:

                    ItemCRUD.get_multi(
                        name__or={'startswith': 'foo', 'endswith': 'bar'}
                    )

There is some mypy issue which I struggle to solve, but it looks like it's not required. The tests pass with good coverage.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (03d4a2d) to head (f8f8713). Report is 16 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #85 +/- ## ========================================== Coverage 100.00% 100.00% ========================================== Files 68 70 +2 Lines 4819 5425 +606 ========================================== + Hits 4819 5425 +606 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

JakNowy commented 1 month ago

@igorbenav this is ready for review. I'm going to add some docs tomorrow.

igorbenav commented 3 weeks ago

I think all that's missing are typing fixes and docs and we're good to go

JakNowy commented 2 weeks ago

@igorbenav Added docs and fixed checks. The latest commit makes the code a bit less clean, but it satisfies mypy, it's up to you if you want to keep it. Let me know your thoughts!

igorbenav commented 2 weeks ago

Looking really good, @JakNowy, great work!