]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
pep484 updates, again
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 28 Mar 2025 13:21:49 +0000 (09:21 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 28 Mar 2025 13:21:49 +0000 (09:21 -0400)
I merged the diff for the other PR as well, had to revert,
trying again

Change-Id: Icc28241d68626496e7c7857edb97eda0a9cf2219

alembic/ddl/base.py
alembic/ddl/impl.py

index bd55c56d570493202a6bd6c9151a65c07325676a..7c36a887326b27f8b46c6d1f04c1955023583385 100644 (file)
@@ -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:
index c116fcfa6120f38e25fe2aeba89c1c63d5834840..96b03f6f7c00956706c58cc843f002dd2d8d5854 100644 (file)
@@ -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: