weixin_39890652 2020-11-30 11:37
浏览 0

drop_constraint() does not quote check constraint name

Migrated issue, originally created by Robert Buchholz ()

Alembic does not quote a constraint name (at least for MariaDB). If it contains a dot, (in the best case) MariaDB will complain (depending on the number of dots) about missing tables or databases. In the worst case, a constraint on a schema and table not referenced by the table and schema arguments might be dropped.

Actual behavior:


(Pdb) op.drop_constraint('foo.bar',table_name='baz', type_='check')
*** ProgrammingError: (pymysql.err.ProgrammingError) (1103, u"Incorrect table name 'foo'") [SQL: u'ALTER TABLE baz DROP CONSTRAINT foo.bar'] (Background on this error at: http://sqlalche.me/e/f405)
(Pdb) op.drop_constraint('fnord.foo.bar',table_name='baz', type_='check')
*** ProgrammingError: (pymysql.err.ProgrammingError) (1102, u"Incorrect database name 'fnord'") [SQL: u'ALTER TABLE baz DROP CONSTRAINT fnord.foo.bar'] (Background on this error at: http://sqlalche.me/e/f405)

Versions:

  • alembic 0.9.8
  • SQLAlchemy 1.2.5
  • MariaDB 10.2.13
  • Python 2.7.14

该提问来源于开源项目:sqlalchemy/alembic

  • 写回答

14条回答 默认 最新

  • weixin_39890652 2020-11-30 11:37
    关注

    Robert Buchholz () wrote:

    FYI: This does not happen on type='foreignkey', type='unique' or op.drop_index.

    评论

报告相同问题?