Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: filter __in #57

Merged
merged 13 commits into from
May 6, 2024
Merged

feat: filter __in #57

merged 13 commits into from
May 6, 2024

Conversation

JakNowy
Copy link
Contributor

@JakNowy JakNowy commented Apr 23, 2024

Pull Request Template for FastCRUD

Description

This PR adds support for in_ filtering in crud methods like FastCRUD.select(item_id__in=[1,2]).

Changes

Extended parse_filters method with addtional elif op == "in", mapping to sqlalchemy/sqlmodel or() filter.

Tests

Added a test to test_parse_filters for both sqlalchemy and sqlmodel.

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have added necessary documentation (if appropriate).
  • I have added tests that cover my changes (if applicable).
  • All new and existing tests passed.

Additional Notes

I was trying to acomplish something similar for or_() but it turned out to be too complex for now.

@JakNowy JakNowy changed the title Filter __in feat: filter __in Apr 23, 2024
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1c9cf66) to head (dad3295).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #57   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         4468      4510   +42     
=========================================
+ Hits          4468      4510   +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JakNowy JakNowy mentioned this pull request Apr 24, 2024
@igorbenav igorbenav self-assigned this Apr 24, 2024
@igorbenav igorbenav added enhancement New feature or request FastCRUD Methods Related to FastCRUD methods labels Apr 24, 2024
@igorbenav
Copy link
Owner

Hey, @JakNowy, thanks for another great PR🎉!
Could you please add an example using __in to a docstring somewhere? I think adding not_in would be good as well. How did you think about adding or?

@igorbenav
Copy link
Owner

@JakNowy did you get a chance to take a look at this?

@JakNowy
Copy link
Contributor Author

JakNowy commented Apr 29, 2024

Hey @igorbenav not yet, but I will definetely add some more docs and not_in support soon! For or, I was thinking about nesting the parse_filters() method in that case to produce something like or(parsed_filter1, parsed_filter2).

@JakNowy
Copy link
Contributor Author

JakNowy commented May 6, 2024

Added not_in support and tests. Although quite simple, looks decent to me. Added short docstring for each fastcrud method, as well as some clarification in docs/advanced/crud. @igorbenav

@igorbenav
Copy link
Owner

For or, I was thinking about nesting the parse_filters() method in that case to produce something like or(parsed_filter1, parsed_filter2).

I'll create another issue for the missing comparison operators, we can handle it there. Thanks for the pr!

@igorbenav igorbenav merged commit b9683ca into igorbenav:main May 6, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request FastCRUD Methods Related to FastCRUD methods
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants