]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix: Fixed a bug that caused a syntax error when a function was specified to server_d...
authorhuuyafwww <huuya1234fwww@gmail.com>
Fri, 4 Oct 2024 17:39:02 +0000 (02:39 +0900)
committerhuuyafwww <huuya1234fwww@gmail.com>
Fri, 4 Oct 2024 17:39:02 +0000 (02:39 +0900)
lib/sqlalchemy/dialects/mysql/base.py

index aa99bf4d6849d24fdae11f5924810e02e748708f..b841a20445926a7ee1acb71644fb6bf5cb6d1c5a 100644 (file)
@@ -1853,6 +1853,11 @@ class MySQLDDLCompiler(compiler.DDLCompiler):
                 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'({column.server_default.arg})'
+        return super().get_column_default_string(column)
+
     def post_create_table(self, table):
         """Build table-level CREATE options like ENGINE and COLLATE."""