From: huuyafwww Date: Fri, 4 Oct 2024 19:44:11 +0000 (+0900) Subject: fix: Directly write the process enclosed in parentheses in get_column_specification X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b0da3cce385c0946726c6bce7163f0eef66772c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fix: Directly write the process enclosed in parentheses in get_column_specification --- diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index e28892ddf0..8b96c26459 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1850,14 +1850,12 @@ class MySQLDDLCompiler(compiler.DDLCompiler): else: default = self.get_column_default_string(column) if default is not None: - colspec.append("DEFAULT " + default) + if isinstance(column.server_default.arg, functions.FunctionElement): + colspec.append(f"DEFAULT ({default})") + else: + colspec.append("DEFAULT " + default) return " ".join(colspec) - def get_column_default_string(self, column): - if hasattr(column.server_default, 'arg') and isinstance(column.server_default.arg, functions.FunctionElement): - return f'({super().get_column_default_string(column)})' - return super().get_column_default_string(column) - def post_create_table(self, table): """Build table-level CREATE options like ENGINE and COLLATE."""