Skip to content

Commit 20188bf

Browse files
committed
Always remove json_schema_extra from schema_extra with Pydantic V2
1 parent 3ad8aa9 commit 20188bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sqlmodel/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,11 @@ def Field(
447447
if IS_PYDANTIC_V2:
448448
# Handle a workaround when json_schema_extra was passed via schema_extra
449449
if "json_schema_extra" in current_schema_extra:
450+
json_schema_extra_from_schema_extra = current_schema_extra.pop(
451+
"json_schema_extra"
452+
)
450453
if not current_json_schema_extra:
451-
current_json_schema_extra = current_schema_extra.pop(
452-
"json_schema_extra"
453-
)
454+
current_json_schema_extra = json_schema_extra_from_schema_extra
454455
# Split parameters from schema_extra to field_info_kwargs and json_schema_extra
455456
for key, value in current_schema_extra.items():
456457
if key in FIELD_ACCEPTED_KWARGS:

0 commit comments

Comments
 (0)