1. Mike Bayer
  2. alembic

Pull requests

#10 Declined
Repository
Deleted repository
Branch
fix_mysql_column_whitespace (46b58a887801)
Repository
alembic
Branch
master

Escape mysql columns with spaces. Fix #152.

Author
  1. Iuri de Silvio
Reviewers
Description

It fixed my problem. I'm not sure if it is the right way to fix it.

Comments (2)

  1. Mike Bayer repo owner

    mmm here we'd need to make use of identifier_preparer, this would need to be done in all the appropriate places for all backends, tests added. Below is how it probably will look (though there also might be some changes to identifier_preparer.quote() across 0.8/0.9 that might need some compat workarounds):

    diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py
    index ed48a59..d73c7cf 100644
    --- a/alembic/ddl/mysql.py
    +++ b/alembic/ddl/mysql.py
    @@ -98,7 +98,7 @@ def _render_value(compiler, expr):
     def _mysql_colspec(compiler, name, nullable, server_default, type_,
                                             autoincrement):
         spec = "%s %s %s" % (
    -        name,
    +        compiler.identifier_preparer.quote(name),
             compiler.dialect.type_compiler.process(type_),
             "NULL" if nullable else "NOT NULL"
         )
    

    so it's not a complicated change but there's a lot of details that need to be attended to.