From: Mike Bayer Date: Fri, 28 Mar 2025 13:21:49 +0000 (-0400) Subject: pep484 updates, again X-Git-Tag: rel_1_15_2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4477ff09a3902da4047ff9b0eeb0cb1b24004d7f;p=thirdparty%2Fsqlalchemy%2Falembic.git pep484 updates, again I merged the diff for the other PR as well, had to revert, trying again Change-Id: Icc28241d68626496e7c7857edb97eda0a9cf2219 --- diff --git a/alembic/ddl/base.py b/alembic/ddl/base.py index bd55c56d..7c36a887 100644 --- a/alembic/ddl/base.py +++ b/alembic/ddl/base.py @@ -299,9 +299,13 @@ def format_server_default( compiler: DDLCompiler, default: Optional[_ServerDefault], ) -> str: - return compiler.get_column_default_string( + # this can be updated to use compiler.render_default_string + # for SQLAlchemy 2.0 and above; not in 1.4 + default_str = compiler.get_column_default_string( Column("x", Integer, server_default=default) ) + assert default_str is not None + return default_str def format_type(compiler: DDLCompiler, type_: TypeEngine) -> str: diff --git a/alembic/ddl/impl.py b/alembic/ddl/impl.py index c116fcfa..96b03f6f 100644 --- a/alembic/ddl/impl.py +++ b/alembic/ddl/impl.py @@ -46,7 +46,6 @@ if TYPE_CHECKING: from sqlalchemy.engine.reflection import Inspector from sqlalchemy.sql import ClauseElement from sqlalchemy.sql import Executable - from sqlalchemy.sql.elements import ColumnElement from sqlalchemy.sql.elements import quoted_name from sqlalchemy.sql.schema import Constraint from sqlalchemy.sql.schema import ForeignKeyConstraint @@ -440,7 +439,7 @@ class DefaultImpl(metaclass=ImplMeta): def drop_table_comment(self, table: Table) -> None: self._exec(schema.DropTableComment(table)) - def create_column_comment(self, column: ColumnElement[Any]) -> None: + def create_column_comment(self, column: Column[Any]) -> None: self._exec(schema.SetColumnComment(column)) def drop_index(self, index: Index, **kw: Any) -> None: