Skip to content

Implement OR and NOT for filtering. #210

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

Conversation

doubledare704
Copy link
Contributor

Pull Request Template for FastCRUD

Description

refactor: improve FastCRUD filter parsing readability and operations

  • Split _parse_filters into smaller, focused helper methods
  • Added proper type hints and docstrings for better clarity
  • Fixed variable shadowing in column handling
  • Improved error handling consistency
  • Added dedicated methods for:
    • _handle_simple_filter
    • _handle_or_filter
    • _handle_not_filter
    • _handle_standard_filter
    • _get_column

Implementation Notes:

  • OR operations: field__or={'gt': 18, 'lt': 65} applies multiple conditions to same field Example: age__or={'gt': 18, 'lt': 65} -> WHERE age > 18 OR age < 65

  • NOT operations: field__not={'eq': value, 'between': (x,y)} applies NOT to each condition
    Example: age__not={'eq': 20, 'between': (30,40)} ->
    WHERE NOT age = 20 AND NOT (age BETWEEN 30 AND 40)

Makes the code more maintainable and easier to test by reducing complexity and improving separation of concerns.

Changes

Briefly list the changes you've made. If applicable, also link any relevant issues or pull requests.

Tests

Describe the tests you added or modified to cover your changes, if applicable.

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

@doubledare704
Copy link
Contributor Author

Related to
Issue1
Issue2

@igorbenav
Copy link
Collaborator

@doubledare704 can you please just fix the typing issues?

- Split _parse_filters into smaller, focused helper methods
- Added proper type hints and docstrings for better clarity
- Fixed variable shadowing in column handling
- Improved error handling consistency
- Added dedicated methods for:
  - _handle_simple_filter
  - _handle_or_filter
  - _handle_not_filter
  - _handle_standard_filter
  - _get_column

Implementation Notes:
- OR operations:
  field__or={'gt': 18, 'lt': 65} applies multiple conditions to same field
  Example: age__or={'gt': 18, 'lt': 65} -> WHERE age > 18 OR age < 65

- NOT operations:
  field__not={'eq': value, 'between': (x,y)} applies NOT to each condition
  Example: age__not={'eq': 20, 'between': (30,40)} ->
  WHERE NOT age = 20 AND NOT (age BETWEEN 30 AND 40)

Makes the code more maintainable and easier to test by reducing complexity
and improving separation of concerns.
@doubledare704 doubledare704 force-pushed the feature/Add-support-for-OR-and-AND-conditions-in-filtering branch from b96efd8 to ff59e11 Compare March 25, 2025 10:16
@igorbenav
Copy link
Collaborator

Great one, @doubledare704, thanks for it!

@igorbenav igorbenav self-requested a review March 26, 2025 00:27
@igorbenav igorbenav merged commit b5242c0 into benavlabs:main Mar 26, 2025
7 checks passed
@doubledare704
Copy link
Contributor Author

@igorbenav seems like types was fixed

@doubledare704 doubledare704 deleted the feature/Add-support-for-OR-and-AND-conditions-in-filtering branch March 27, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants