pydantic-sqlalchemy
pydantic-sqlalchemy copied to clipboard
add support for @property and @hybrid_property
This PR adds support for attributes defined by @property or @hybrid_property. The corresponding functions must provide a type hint for the return type.
I'm not sure if I identify hybrid_properties the right way, or if the check is to broad.
Codecov Report
Merging #26 (b7b9608) into master (8667e21) will not change coverage. The diff coverage is
100.00%.
:exclamation: Current head b7b9608 differs from pull request most recent head 7583638. Consider uploading reports for the commit 7583638 to get more accurate results
@@ Coverage Diff @@
## master #26 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 3 +1
Lines 127 215 +88
=========================================
+ Hits 127 215 +88
| Impacted Files | Coverage Δ | |
|---|---|---|
| pydantic_sqlalchemy/main.py | 100.00% <100.00%> (ø) |
|
| tests/conftest.py | 100.00% <100.00%> (ø) |
|
| tests/test_pydantic_sqlalchemy.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 8667e21...7583638. Read the comment docs.
Hm, I see no chance to get the test coverage to 100% when having if TYPE_CHECKING: in the code :cry:
You can get hybrid attributes with the hybrid_attributes property: db_model.hybrid_attributes. Maybe just merge both, mapper.attributes and db_model.hybrid_attributes when doing the for loop works out?
Thank you for all the work you put here @finswimmer! :nerd_face:
Thanks for the patience with my reply. :sweat_smile:
I deprecated this library a while ago in favor of SQLModel which would solve all the same use cases in a much better way, and I'm directing all the effort in that direction, so sadly I wouldn't be able to take new features here (that would also need maintaining them).
Given that, I'll close this one, but thanks for the effort! :coffee: