Fix get_sqlachemy_type() not checking for the ModelField.type_ to be a scalar type first
Currently using Dict[...], List[...] or Union[...] will break with an error stating that issubclass() cannot be used for non types. This is something users won't understand and I think SQLModel should handle this in a better way.
PR will fix the issue and contains a test to validate the code was broken before and is now fixed. The normal ValueError(f"The field {field.name} has no matching SQLAlchemy type") will then be raised.
📝 Docs preview for commit 7967bcb48393aeea1e1ece2e4b64b8eb5fb22e36 at: https://630cda8afbefa94f41c70df1--sqlmodel.netlify.app
Codecov Report
Attention: 12 lines in your changes are missing coverage. Please review.
Comparison is base (
ea79c47) 98.49% compared to head (55c10b5) 97.73%. Report is 50 commits behind head on main.
:exclamation: Current head 55c10b5 differs from pull request most recent head 4e376df. Consider uploading reports for the commit 4e376df to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #425 +/- ##
==========================================
- Coverage 98.49% 97.73% -0.77%
==========================================
Files 185 187 +2
Lines 5856 6212 +356
==========================================
+ Hits 5768 6071 +303
- Misses 88 141 +53
| Files | Coverage Δ | |
|---|---|---|
| tests/test_get_sqlachemy_type.py | 100.00% <100.00%> (ø) |
|
| sqlmodel/main.py | 84.72% <67.56%> (ø) |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
📝 Docs preview for commit 55c10b5b97142875044b35ac4c3b91ce4e910de9 at: https://630cfc073e4a7000b12222dd--sqlmodel.netlify.app
Thanks! I updated the tests to use models, as that would be a realistic use case, then I fixed a small bug in the implementation detected by that.
This will be available in the next release. 🤓
Thx for merging this! 🥳