diff --git a/sqlmodel/main.py b/sqlmodel/main.py index d343c698e9..59d5dcaa59 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -372,6 +372,8 @@ def __init__( def get_sqlachemy_type(field: ModelField) -> Any: + if issubclass(field.type_, Enum): + return sa_Enum(field.type_) if issubclass(field.type_, str): if field.field_info.max_length: return AutoString(length=field.field_info.max_length) @@ -390,8 +392,6 @@ def get_sqlachemy_type(field: ModelField) -> Any: return Interval if issubclass(field.type_, time): return Time - if issubclass(field.type_, Enum): - return sa_Enum(field.type_) if issubclass(field.type_, bytes): return LargeBinary if issubclass(field.type_, Decimal):