-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
✨ Add support for Decimal fields from Pydantic and SQLAlchemy #103
Conversation
Codecov Report
@@ Coverage Diff @@
## main #103 +/- ##
==========================================
+ Coverage 97.27% 97.43% +0.16%
==========================================
Files 175 177 +2
Lines 5842 5895 +53
==========================================
+ Hits 5683 5744 +61
+ Misses 159 151 -8
Continue to review full report at Codecov.
|
📝 Docs preview for commit b3097dd at: https://61b7250eedfd1107eee4102a--sqlmodel.netlify.app |
📝 Docs preview for commit f3ee8b9 at: https://61b72675216a992d57cdf825--sqlmodel.netlify.app |
📝 Docs preview for commit 0a83e2b at: https://61b72e60030c1ad58c750965--sqlmodel.netlify.app |
Awesome! Thanks for the contribution and the support @robcxyz! 🚀 🎉 I updated the docs and tests, this now has its own section in the advanced docs explaining a bit how decimals work: https://sqlmodel.tiangolo.com/advanced/decimal/ Before updating and merging this I also added this PR to Pydantic, which means that in the next Pydantic version we'll be able to have types annotated with This is now included in the (just released) SQLModel |
Per issue #30 - condecimal attributes aren't passed down into sqlalchemy types. This PR fixes that by mapping pydantic's condecimal arguments
max_digits
anddecimal_places
to sqlalchemy's decimal argumentsprecision
andscale
respectively.main.py #395
Also adds an example with a test in the
code_structure
tutorial with a condecimal field with a few options.