Skip to content

Commit f7d86ec

Browse files
committed
📝 Fix type alias handling in _compat.py
1 parent 2bfcad1 commit f7d86ec

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sqlmodel/_compat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def partial_init() -> Generator[None, None, None]:
8181
from pydantic._internal._repr import Representation as Representation
8282
from pydantic_core import PydanticUndefined as Undefined
8383
from pydantic_core import PydanticUndefinedType as UndefinedType
84+
from typing import TypeAliasType
8485

8586
# Dummy for types, to make it importable
8687
class ModelField:
@@ -203,6 +204,8 @@ def get_sa_type_from_type_annotation(annotation: Any) -> Any:
203204
# Resolve Optional fields
204205
if annotation is None:
205206
raise ValueError("Missing field type")
207+
if isinstance(annotation, TypeAliasType):
208+
annotation = annotation.__value__
206209
origin = get_origin(annotation)
207210
if origin is None:
208211
return annotation

0 commit comments

Comments
 (0)