Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions sqlmodel/main.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,8 +46,9 @@
from sqlalchemy.orm.attributes import set_attribute
from sqlalchemy.orm.decl_api import DeclarativeMeta
from sqlalchemy.orm.instrumentation import is_instrumented
from sqlalchemy.sql.schema import MetaData
from sqlalchemy.sql.schema import MetaData, SchemaEventTarget
from sqlalchemy.sql.sqltypes import LargeBinary, Time, Uuid
from sqlalchemy.types import TypeEngine
from typing_extensions import Literal, TypeAlias, deprecated, get_origin

from ._compat import ( # type: ignore[attr-defined]
Expand DownExpand Up@@ -92,6 +93,11 @@
Mapping[int, Union["IncEx", bool]],
Mapping[str, Union["IncEx", bool]],
]
SaTypeOrInstance: TypeAlias = Union[
TypeEngine[Any],
type[TypeEngine[Any]],
SchemaEventTarget,
]
OnDeleteType = Literal["CASCADE", "SET NULL", "RESTRICT"]


Expand DownExpand Up@@ -240,7 +246,7 @@ def Field(
unique: Union[bool, UndefinedType] = Undefined,
nullable: Union[bool, UndefinedType] = Undefined,
index: Union[bool, UndefinedType] = Undefined,
sa_type: Union[type[Any], UndefinedType] = Undefined,
sa_type: Union[SaTypeOrInstance, UndefinedType] = Undefined,
sa_column_args: Union[Sequence[Any], UndefinedType] = Undefined,
sa_column_kwargs: Union[Mapping[str, Any], UndefinedType] = Undefined,
schema_extra: Optional[dict[str, Any]] = None,
Expand DownExpand Up@@ -284,7 +290,7 @@ def Field(
unique: Union[bool, UndefinedType] = Undefined,
nullable: Union[bool, UndefinedType] = Undefined,
index: Union[bool, UndefinedType] = Undefined,
sa_type: Union[type[Any], UndefinedType] = Undefined,
sa_type: Union[SaTypeOrInstance, UndefinedType] = Undefined,
sa_column_args: Union[Sequence[Any], UndefinedType] = Undefined,
sa_column_kwargs: Union[Mapping[str, Any], UndefinedType] = Undefined,
schema_extra: Optional[dict[str, Any]] = None,
Expand DownExpand Up@@ -369,7 +375,7 @@ def Field(
unique: Union[bool, UndefinedType] = Undefined,
nullable: Union[bool, UndefinedType] = Undefined,
index: Union[bool, UndefinedType] = Undefined,
sa_type: Union[type[Any], UndefinedType] = Undefined,
sa_type: Union[SaTypeOrInstance, UndefinedType] = Undefined,
sa_column: Union[Column, UndefinedType] = Undefined, # type: ignore
sa_column_args: Union[Sequence[Any], UndefinedType] = Undefined,
sa_column_kwargs: Union[Mapping[str, Any], UndefinedType] = Undefined,
Expand Down