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

Fixed issue where "Empty" and "Not Empty" filters raised NotImplementedError on SQLAlchemy relationship attributes #394

Merged
merged 5 commits into from
Nov 14, 2023

Conversation

whchi
Copy link
Contributor

@whchi whchi commented Nov 11, 2023

When using sqlalchemy as database with the filter feature's "Empty" and "Not Empty", it works well for column but not for the relation fields(HasMany, HasOne)

截圖 2023-11-11 下午12 07 31

throws error

# is_not_null
NotImplementedError: <function is_not at 0x105ace200>
# is_null
NotImplementedError: <function is_ at 0x105ace200>

Because the operator of sqlalchemy only works on columns not relationship

# starlette_admin/contrib/sqla/helpers.py
OPERATORS ={
   ...
    "is_null": lambda f, v: f.is_(None),
    "is_not_null": lambda f, v: f.is_not(None),
}

This PR fix this issue

Copy link

codecov bot commented Nov 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9646fbe) 100.00% compared to head (c74fdc3) 100.00%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #394   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           72        72           
  Lines         5559      5579   +20     
=========================================
+ Hits          5559      5579   +20     
Files Coverage Δ
starlette_admin/contrib/sqla/helpers.py 100.00% <100.00%> (ø)
tests/sqla/test_sync_engine.py 100.00% <100.00%> (ø)

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

Copy link
Owner

@jowilf jowilf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution 🎉

@jowilf jowilf changed the title Fix sqlalchemy relationship filter issue Fixed issue where "Empty" and "Not Empty" filters raised NotImplementedError on SQLAlchemy relationship attributes Nov 14, 2023
@jowilf jowilf merged commit 74698b0 into jowilf:main Nov 14, 2023
9 checks passed
@jowilf jowilf mentioned this pull request Nov 14, 2023
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.

None yet

2 participants