Alias and Type Hint Challenges in SQLModel and Pydantic Integration #962
Replies: 3 comments 1 reply
-
you would want to use |
Beta Was this translation helpful? Give feedback.
1 reply
-
Maybe related: https://docs.pydantic.dev/latest/concepts/fields/#field-aliases (under "VSCode and Pyright users") and pydantic/pydantic#5893 |
Beta Was this translation helpful? Give feedback.
0 replies
-
There is already open issue to track this: #203 The workaround is to add from sqlmodel import SQLModel, Field
class Model(SQLModel):
id_: int = Field(alias='id', schema_extra={"validation_alias": "id"})
model = Model(id = 23)
print(model) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
it works correctly but there is some issue with typing in sqlmodel.
I googled on how to use PYDANTIC ALIAS NOT SQLALCHEMY ALIAS in sqlmodel and found nothing helpful.
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.18
Python Version
3.12.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions