sqlmodel icon indicating copy to clipboard operation
sqlmodel copied to clipboard

Fix get_sqlachemy_type() not checking for the ModelField.type_ to be a scalar type first

Open ddanier opened this issue 3 years ago • 3 comments

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.

ddanier avatar Aug 29 '22 15:08 ddanier

📝 Docs preview for commit 7967bcb48393aeea1e1ece2e4b64b8eb5fb22e36 at: https://630cda8afbefa94f41c70df1--sqlmodel.netlify.app

github-actions[bot] avatar Aug 29 '22 15:08 github-actions[bot]

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

... and 2 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 29 '22 15:08 codecov[bot]

📝 Docs preview for commit 55c10b5b97142875044b35ac4c3b91ce4e910de9 at: https://630cfc073e4a7000b12222dd--sqlmodel.netlify.app

github-actions[bot] avatar Aug 29 '22 17:08 github-actions[bot]

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. 🤓

tiangolo avatar Oct 23 '23 06:10 tiangolo

Thx for merging this! 🥳

ddanier avatar Oct 23 '23 08:10 ddanier