Automatically generated index name is too long (MySQL)

Issue #1412 resolved
Former user created an issue

I have a table definition like this:

Table( 'zyrenian_zyme_zyzzogeton_zyzzogeton', metadata, Column('zyrenian_zyme_zyzzogeton_zyrenian_zo', CHAR(36), primary_key=True), Column('zyrenian_zyme_zyzzogeton_zo', CHAR(36), nullable=False, index=True), mysql_engine='InnoDB')

When SA executes resulting DDL statements against a MySQL engine, I get this error:

sqlalchemy.exc.OperationalError: (OperationalError) (1059, "Identifier name 'ix_zyrenian_zyme_zyzzogeton_zyzzogeton_zyrenian_zyme_zyzzogeton_zo' is too long") u'CREATE INDEX ix_zyrenian_zyme_zyzzogeton_zyzzogeton_zyrenian_zyme_zyzzogeton_zo ON zyrenian_zyme_zyzzogeton_zyzzogeton (zyrenian_zyme_zyzzogeton_zo)'

To mitigate, I had to explicitly define an index with a shorter name.

Comments (5)

  1. Michael Trier

    I'm not sure why

        max_identifier_length = 255
    

    for mysql. Sure Alias supports 256 characters but every other identifier supports 64. We should limit it to 64 unless someone wants to provide their own. Seems like the path of least problems.

  2. Mike Bayer repo owner

    I would assume this bug at this point is fixed by #1855, if it weren't fixed already - the test above seems to not even include the _1 that would have occurred. We can give it a quick test perhaps to verify.

  3. Log in to comment