Skip to content

Commit

Permalink
Update _utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
0x587 authored Sep 13, 2023
1 parent 74aa558 commit 6fbf927
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fastapi_crudrouter/core/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def __init__(self, *args, **kwargs) -> None: # type: ignore

def get_pk_type(schema: Type[PYDANTIC_SCHEMA], pk_field: str) -> Any:
try:
return schema.__fields__[pk_field].type_
if int(pydantic_version.split(".")[0]) >= 2:
return schema.model_fields[pk_field].annotation
else:
return schema.__fields__[pk_field].type_
except KeyError:
return int

Expand Down

0 comments on commit 6fbf927

Please sign in to comment.