mirror of
https://github.com/PaiGramTeam/sqlmodel.git
synced 2024-11-22 07:08:06 +00:00
fix type check for sa_column
This commit is contained in:
parent
f3e7811a80
commit
9e07c1c772
@ -167,7 +167,7 @@ def Field(
|
||||
unique: bool = False,
|
||||
nullable: Union[bool, PydanticUndefinedType] = PydanticUndefined,
|
||||
index: Union[bool, PydanticUndefinedType] = PydanticUndefined,
|
||||
sa_column: Union[Column, PydanticUndefinedType, types.FunctionType] = PydanticUndefined, # type: ignore
|
||||
sa_column: Union[Column, PydanticUndefinedType, Callable[[], Column]] = PydanticUndefined, # type: ignore
|
||||
sa_column_args: Union[Sequence[Any], PydanticUndefinedType] = PydanticUndefined,
|
||||
sa_column_kwargs: Union[
|
||||
Mapping[str, Any], PydanticUndefinedType
|
||||
@ -525,7 +525,9 @@ def get_column_from_field(field: FieldInfo) -> Column: # type: ignore
|
||||
if isinstance(sa_column, MappedColumn):
|
||||
return sa_column.column
|
||||
if isinstance(sa_column, types.FunctionType):
|
||||
return sa_column()
|
||||
col = sa_column()
|
||||
assert isinstance(col, Column)
|
||||
return col
|
||||
sa_type = get_sqlalchemy_type(field)
|
||||
primary_key = getattr(field, "primary_key", False)
|
||||
index = getattr(field, "index", PydanticUndefined)
|
||||
|
@ -8,7 +8,6 @@ from sqlalchemy.sql.type_api import TypeEngine
|
||||
|
||||
|
||||
class AutoString(types.TypeDecorator): # type: ignore
|
||||
|
||||
impl = types.String
|
||||
cache_ok = True
|
||||
mysql_default_length = 255
|
||||
|
Loading…
Reference in New Issue
Block a user