Skip to content

Commit cdc863d

Browse files
committed
Test literal patch in _compat
1 parent 859a4af commit cdc863d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sqlmodel/_compat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,12 @@ def is_field_noneable(field: "FieldInfo") -> bool:
460460
)
461461
return field.allow_none # type: ignore[no-any-return, attr-defined]
462462

463-
# def get_sa_type_from_field(field: Any) -> Any:
464-
# if field is Literal:
465-
# return AutoString
466-
# elif isinstance(field.type_, type) and field.shape == SHAPE_SINGLETON:
467-
# return field.type_
468-
# raise ValueError(f"The field {field.name} has no matching SQLAlchemy type")
463+
def get_sa_type_from_field(field: Any) -> Any:
464+
if get_origin(field.type_) is Literal:
465+
return AutoString
466+
elif isinstance(field.type_, type) and field.shape == SHAPE_SINGLETON:
467+
return field.type_
468+
raise ValueError(f"The field {field.name} has no matching SQLAlchemy type")
469469

470470
def get_field_metadata(field: Any) -> Any:
471471
metadata = FakeMetadata()

0 commit comments

Comments
 (0)