Skip to content

Commit 35c5b40

Browse files
committed
Add check for Literal type annotation in get_sqlalchemy_type to return an AutoString
1 parent fee8227 commit 35c5b40

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sqlmodel/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,9 @@ def get_sqlalchemy_type(field: Any) -> Any:
655655
type_ = get_sa_type_from_field(field)
656656
metadata = get_field_metadata(field)
657657

658+
# Checks for `Literal` type annotation
659+
if type_ is Literal:
660+
return AutoString
658661
# Check enums first as an enum can also be a str, needed by Pydantic/FastAPI
659662
if issubclass(type_, Enum):
660663
return sa_Enum(type_)

0 commit comments

Comments
 (0)