-
-
Notifications
You must be signed in to change notification settings - Fork 721
Document using SQLAlchemy column types; add pydantic.EmailStr support #762
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
base: main
Are you sure you want to change the base?
Conversation
📝 Docs preview for commit 8bd9068 at: https://23112ba0.sqlmodel.pages.dev |
8bd9068
to
165e9c5
Compare
📝 Docs preview for commit 0e8c5bc at: https://cb2b259d.sqlmodel.pages.dev |
source_ip_address: IPvAnyAddress | ||
upload_location: Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised to find sqlmodel/pydantic don't convert these values to string for persistence or back into the IP/Path types on retrieval. I think the solution is to implement a Pydantic type, but perhaps I'm doing something wrong here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bug in the pydantic v2 implementation because it used to convert it back to native python types. I've seen it happen with datetimes as well.
Edit: never mind, this has been a problem for quick a while.
0e8c5bc
to
9964b07
Compare
📝 Docs preview for commit 7aead7f at: https://f76c7357.sqlmodel.pages.dev |
📝 Docs preview for commit bae753d at: https://c988b4c3.sqlmodel.pages.dev |
e841517
to
8cd7c17
Compare
📝 Docs preview for commit 8cd7c17 at: https://2b2d516a.sqlmodel.pages.dev |
📝 Docs preview for commit 8c45261 at: https://8390b32c.sqlmodel.pages.dev |
📝 Docs preview for commit 9a0c172 at: https://fe6eeaf3.sqlmodel.pages.dev |
Any update on this MR? |
Bump! This is much needed |
When I start a new project, I typically start with a User model and always bump into this error:
Today I decided to dig into this, and found that
EmailStr
doesn't subclassstr
, which explains why it needs aField(sa_type=String())
. I noticed the AutoString types for ipaddress & pathlib, and figuredEmailStr
might be popular enough to be worth adding (example discussion).As part of this, in order to test that change I've started documenting how SA column types work in SQLModel. I also noticed the mention about varchar length and documented that too.
Let me know if you'd prefer this as two separate PRs and I can cherry-pick it out - they're only together as I wanted to use the docs-tutorial tests (which are awesome!)
pydantic.EmailStr
support toget_sqlalchemy_type
Finish testing "exotic sqlalchemy type" (geoalchemy2) tests