Skip to content

Commit

Permalink
Update _utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
calebnorman committed Nov 15, 2023
1 parent 94e6017 commit fe80b9e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fastapi_crudrouter/core/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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_
return schema.model_fields[pk_field].annotation
except KeyError:
return int

Expand All @@ -27,8 +27,8 @@ def schema_factory(
"""

fields = {
f.name: (f.type_, ...)
for f in schema_cls.__fields__.values()
f.alias: (f.annotation, f)
for f in schema_cls.model_fields.values()
if f.name != pk_field_name
}

Expand Down

0 comments on commit fe80b9e

Please sign in to comment.