Passing schema_extra
to Field has changed in Pydantic 2.0 but not in SQLModel.
#833
-
First Check
Commit to Help
Example CodeNo code to show. See the description. DescriptionPydanticV1's PydanticV2 still supports passing extra things to the JSON schema but in a slightly different way. One has to pass a dictionary in the Currently, SQLModel does not reflect the corresponding change in its Field implementation. From what I can tell, it's simply about making one line change to the call here (call to Pydantic's FieldInfo). # from:
**current_schema_extra,
# to:
json_schema_extra=current_schema_extra, For consistency with Pydantic, it may also be better to rename Operating SystemmacOS Operating System DetailsNo response SQLModel Version0.0.16 Python Version3.11.0 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
Okay, it's been over a week and I am fairly positive this is a bug. So tagging @tiangolo, @maru0123-2004 @daniil-berg, @raphaelgibson based on who have made commits to the lines surrounding the bug. I'll appreciate the help, thank you! |
Beta Was this translation helpful? Give feedback.
-
@tiangolo Gentle reminder here. |
Beta Was this translation helpful? Give feedback.
-
Same issue. There is a prevision of when it would be changed? |
Beta Was this translation helpful? Give feedback.
-
Same issue. |
Beta Was this translation helpful? Give feedback.
-
Sorry for late replying. There may exists problem for argument naming, but it is not bad than mine. My contribution is not affected to this problem, I think. But if there are more problem having relation with my code, please mention again. P.S. Sorry for bad my English. |
Beta Was this translation helpful? Give feedback.
-
The behavior is even more cursed if you try and work around it by using from sqlmodel import SQLModel
from pydantic import Field
class MyModel(SQLModel):
x: int = Field(json_schema_extra={'key': 'value'})
MyModel.model_fields['x']
# FieldInfo(..., json_schema_extra={'schema_extra': {'json_schema_extra': {'key': 'so'}}}) |
Beta Was this translation helpful? Give feedback.
-
AFAIK it's not documented, but For example, there is no id_: in = Field(schema_extra={"validation_alias": "item_id"}) |
Beta Was this translation helpful? Give feedback.
AFAIK it's not documented, but
schema_extra
parameter of SQLModel'sField
is for passing parameters that are not present in theField
, but supported by Pydantic'sField
.For example, there is no
validation_alias
parameter, but you can pass it the following way: