Skip to content

Commit e522d9d

Browse files
committed
fix case where AutoString is being converted
1 parent ce968ea commit e522d9d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sqlmodel/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
Numeric,
4040
inspect,
4141
)
42+
from sqlalchemy import types as sa_types
4243
from sqlalchemy import Enum as sa_Enum
4344
from sqlalchemy.orm import (
4445
Mapped,
@@ -656,6 +657,10 @@ def get_sqlalchemy_type(field: Any) -> Any:
656657
type_ = get_sa_type_from_field(field)
657658
metadata = get_field_metadata(field)
658659

660+
# If it's already an SQLAlchemy type (eg. AutoString), use it directly
661+
if isinstance(type_, type) and issubclass(type_, sa_types.TypeEngine):
662+
return type_
663+
659664
# Checks for `Literal` type annotation
660665
if type_ is Literal:
661666
return AutoString

0 commit comments

Comments
 (0)