✨ Add support for all `Field` parameters from Pydantic version `1.9.0`
Summary
The proposed changes add support for the following Field parameters:
-
max_digits -
decimal_places -
unique_items -
discriminator -
repr
This makes the SQLModel Field constructor support all Pydantic field parameters as of version 1.9.0 up until the current one (1.10.2).
Tests sub-package for Pydantic capabilities was added and tests for the new field parameters were included.
The Pydantic dependency was bumped to 1.9.0.
Fixes
- #354 - more elegant solution
- #356 - fulfills feature request
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
ea79c47) 98.49% compared to head (57e05ab) 97.81%. Report is 94 commits behind head on main.
:exclamation: Current head 57e05ab differs from pull request most recent head 8bc6450. Consider uploading reports for the commit 8bc6450 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #440 +/- ##
==========================================
- Coverage 98.49% 97.81% -0.69%
==========================================
Files 185 188 +3
Lines 5856 6315 +459
==========================================
+ Hits 5768 6177 +409
- Misses 88 138 +50
| Files | Coverage Δ | |
|---|---|---|
| sqlmodel/main.py | 85.50% <100.00%> (ø) |
|
| tests/test_pydantic/test_field.py | 100.00% <100.00%> (ø) |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
📝 Docs preview for commit 6728c25bec264152e84818b8c42fa3d480540cfc at: https://63186d6a24607c220a2e25b4--sqlmodel.netlify.app
📝 Docs preview for commit 57e05abeda76179b96f4af629a3677c72d1a7e50 at: https://63187ebf24607c32762e235c--sqlmodel.netlify.app
📝 Docs preview for commit 45d5eb1ee3903e4ceec4e6b239ee7df12039169c at: https://639ce0c089c20f00aba4cd75--sqlmodel.netlify.app
@tiangolo Is there any planned timeline to merge this PR? Discriminator is a need for many developers (that's why pydantic released a support for it). It could really make our lives way better as devs using SQLModel.
Thanks
@tiangolo any update on this?
++ on updates
📝 Docs preview for commit 5ff6d2a97edfc1fe9f467d9c6e7b128ccecdada3 at: https://de370077.sqlmodel.pages.dev
Awesome, thank you @daniil-berg! 🚀
This will be available in the next version: 0.0.10 🎉