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

✨ Add support for all Field parameters from Pydantic 1.9.0 and above, make Pydantic 1.9.0 the minimum required version #440

Merged
merged 6 commits into from Oct 26, 2023

Conversation

daniil-berg
Copy link
Contributor

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

(incl. `max_digits`, `decimal_places`, `unique_items`, `discriminator`, and `repr`);
add tests for Pydantic capabilities;
bump Pydantic dependency to `1.9.0`
@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ea79c47) 98.49% compared to head (57e05ab) 97.81%.
Report is 94 commits behind head on main.

❗ 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%> (ø)

... and 1 file with indirect coverage changes

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

@github-actions
Copy link

github-actions bot commented Sep 7, 2022

📝 Docs preview for commit 6728c25 at: https://63186d6a24607c220a2e25b4--sqlmodel.netlify.app

@github-actions
Copy link

github-actions bot commented Sep 7, 2022

📝 Docs preview for commit 57e05ab at: https://63187ebf24607c32762e235c--sqlmodel.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 45d5eb1 at: https://639ce0c089c20f00aba4cd75--sqlmodel.netlify.app

@rotemvilsa
Copy link

@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

@pajowu
Copy link

pajowu commented Mar 14, 2023

@tiangolo any update on this?

@N-Demir
Copy link

N-Demir commented Sep 28, 2023

++ on updates

@tiangolo tiangolo added the feature New feature or request label Oct 22, 2023
@github-actions
Copy link

📝 Docs preview for commit 5ff6d2a at: https://de370077.sqlmodel.pages.dev

@tiangolo tiangolo changed the title ✨ Add support for all Field parameters from Pydantic version 1.9.0 ✨ Add support for all Field parameters from Pydantic 1.9.0 and above, make Pydantic 1.9.0 the minimum required version Oct 26, 2023
@tiangolo
Copy link
Owner

Awesome, thank you @daniil-berg! 🚀

This will be available in the next version: 0.0.10 🎉

@tiangolo tiangolo merged commit 99f8ce3 into tiangolo:main Oct 26, 2023
11 checks passed
with pytest.raises(ValidationError):
Model(unique_strings=["x", "y", "x"])


Copy link

Choose a reason for hiding this comment

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

why remove and not skipif, as pydantic v2 support is not present now?

Please note that if that means Pydantic v2 support in few days, I'm fine with it ;-)

Copy link
Owner

Choose a reason for hiding this comment

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

Yep, the plan is to support SQLAlchemy 2.0 and Pydantic 2.0 as soon as possible. 🤓

@tiangolo tiangolo mentioned this pull request Nov 2, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants