1. Michael Bayer
  2. alembic
  3. Pull requests

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. iurisilvio
Reviewers
Description

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

  • Issues #152: MySQL alter column breaks with spaces resolved

Comments (2)

  1. Michael 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.

  2. iurisilvio author

    Makes sense. I will use this hack for now and wait for the proper solution. This PR can be useful to someone with the same issue.

    Thanks!