Skip to content

Commit 19859fa

Browse files
authored
Added typecheck to sqlalchemy JSON
In sqlmodel/main.py there was missing a typecheck for the JSON type supported by sqlalchemy. So it was not possible to define a model with a JSON field.
1 parent df0f834 commit 19859fa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sqlmodel/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from sqlalchemy.orm.decl_api import DeclarativeMeta
5252
from sqlalchemy.orm.instrumentation import is_instrumented
5353
from sqlalchemy.sql.schema import MetaData
54-
from sqlalchemy.sql.sqltypes import LargeBinary, Time
54+
from sqlalchemy.sql.sqltypes import LargeBinary, Time, JSON
5555
from typing_extensions import Literal, deprecated, get_origin
5656

5757
from ._compat import ( # type: ignore[attr-defined]
@@ -612,6 +612,8 @@ def get_sqlalchemy_type(field: Any) -> Any:
612612
return AutoString
613613
if issubclass(type_, uuid.UUID):
614614
return GUID
615+
if issubclass(type_, JSON):
616+
return JSON
615617
raise ValueError(f"{type_} has no matching SQLAlchemy type")
616618

617619

0 commit comments

Comments
 (0)