Uh oh!
There was an error while loading. Please reload this page.
Replies: 10 comments 4 replies
@DurandA I was facing the same issue thanks for creating this! |
Looks like the pydantic SchemaValidator.validate_python (https://docs.pydantic.dev/latest/api/pydantic_core/#pydantic_core._pydantic_core.SchemaValidator.validate_python) doesn't handle aliases. That is what is used to set the fields of an object here: |
related: #774 |
I can't make .model_dump(by_alias=True) work. It always uses the attribute name. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Did anyone find a workaround? The one mentioned in #290 seems to be working only for table-models. |
Also facing this issue |
for me this workaround works for pydanticv 2.6 sqlmodel 0.0.14 its similar to what #774 does fromsqlmodelimportSQLModel, FieldclassTest:
def__init__(self, test):
self.Test=testclassItem(SQLModel):
test: str=Field(schema_extra={"validation_alias": "Test"})
t1=Test("1")
Item.model_validate(t1)
Item.model_validate({"Test": "1"}) |
I'm facing this issue as well and the above solution doesn't help with dumping |
Thanks for reporting! Created issue to track this: #1536 |
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
Modelwith aFieldthat contain an aliasOperating System
Linux
Operating System Details
No response
SQLModel Version
0.0.14
Python Version
Python 3.12.0
Additional Context
This issue appeared on SQLModel 0.0.14.
All reactions