<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">The following field/index produces an error in SA 0.4.2 / MySQL 5:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="table = sa.Table('resource_path', self.db_metadata,
            sa.Column('id',             sa.Integer,     primary_key = True),
            sa.Column('path',           sa.Binary(255), index = True),
            mysql_engine='INNODB'
        )
table.create(checkfirst = True)"><pre class="notranslate"><code class="notranslate">table = sa.Table('resource_path', self.db_metadata,
            sa.Column('id',             sa.Integer,     primary_key = True),
            sa.Column('path',           sa.Binary(255), index = True),
            mysql_engine='INNODB'
        )
table.create(checkfirst = True)
</code></pre></div>
<p dir="auto">The complete error message is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;Guard/DBTest.py&quot;, line 43, in setUp
    self.assert_(self.db.install())
  File &quot;/home/sam/code/spiff_guard/tests/Guard/../../src/Guard/DB.py&quot;,
line 35, in install
    table.create(checkfirst = True)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/schema.py&quot;, line 300, in create
    self.metadata.create_all(bind=bind, checkfirst=checkfirst,
tables=[self](self))
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/schema.py&quot;, line 1215, in create_all
    bind.create(self, checkfirst=checkfirst, tables=tables)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 1131, in create
    self._run_visitor(self.dialect.schemagenerator, entity, connection=connection, **kwargs)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 1160, in _run_visitor
    visitorcallable(self.dialect, conn, **kwargs).traverse(element)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py&quot;, line 76, in traverse
    meth(target)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/sql/compiler.py&quot;, line 760, in visit_metadata
    self.traverse_single(table)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py&quot;, line 30, in traverse_single
    return meth(obj, **kwargs)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/sql/compiler.py&quot;, line 796, in visit_table
    self.traverse_single(index)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py&quot;, line 30, in traverse_single
    return meth(obj, **kwargs)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/sql/compiler.py&quot;, line 881, in visit_index
    self.execute()
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 1760, in execute
    return self.connection.execute(self.buffer.getvalue())
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 844, in execute
    return Connection.executors[c](c)(self, object, multiparams, params)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 854, in _execute_text
    self.__execute_raw(context)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 916, in __execute_raw
    self._cursor_execute(context.cursor, context.statement, context.parameters[0](0), context=context)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 953, in _cursor_execute
    self._handle_dbapi_exception(e, statement, parameters, cursor)
  File &quot;/var/lib/python-support/python2.5/sqlalchemy/engine/base.py&quot;, line 935, in _handle_dbapi_exception
    raise exceptions.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect)
OperationalError: (OperationalError) (1170, &quot;BLOB/TEXT column 'path' used in key specification without a key length&quot;) 'CREATE INDEX
ix_guard_resource_path_path ON guard_resource_path (path)' {}"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "Guard/DBTest.py", line 43, in setUp
    self.assert_(self.db.install())
  File "/home/sam/code/spiff_guard/tests/Guard/../../src/Guard/DB.py",
line 35, in install
    table.create(checkfirst = True)
  File "/var/lib/python-support/python2.5/sqlalchemy/schema.py", line 300, in create
    self.metadata.create_all(bind=bind, checkfirst=checkfirst,
tables=[self](self))
  File "/var/lib/python-support/python2.5/sqlalchemy/schema.py", line 1215, in create_all
    bind.create(self, checkfirst=checkfirst, tables=tables)
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 1131, in create
    self._run_visitor(self.dialect.schemagenerator, entity, connection=connection, **kwargs)
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 1160, in _run_visitor
    visitorcallable(self.dialect, conn, **kwargs).traverse(element)
  File "/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py", line 76, in traverse
    meth(target)
  File "/var/lib/python-support/python2.5/sqlalchemy/sql/compiler.py", line 760, in visit_metadata
    self.traverse_single(table)
  File "/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py", line 30, in traverse_single
    return meth(obj, **kwargs)
  File "/var/lib/python-support/python2.5/sqlalchemy/sql/compiler.py", line 796, in visit_table
    self.traverse_single(index)
  File "/var/lib/python-support/python2.5/sqlalchemy/sql/visitors.py", line 30, in traverse_single
    return meth(obj, **kwargs)
  File "/var/lib/python-support/python2.5/sqlalchemy/sql/compiler.py", line 881, in visit_index
    self.execute()
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 1760, in execute
    return self.connection.execute(self.buffer.getvalue())
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 844, in execute
    return Connection.executors[c](c)(self, object, multiparams, params)
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 854, in _execute_text
    self.__execute_raw(context)
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 916, in __execute_raw
    self._cursor_execute(context.cursor, context.statement, context.parameters[0](0), context=context)
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 953, in _cursor_execute
    self._handle_dbapi_exception(e, statement, parameters, cursor)
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 935, in _handle_dbapi_exception
    raise exceptions.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect)
OperationalError: (OperationalError) (1170, "BLOB/TEXT column 'path' used in key specification without a key length") 'CREATE INDEX
ix_guard_resource_path_path ON guard_resource_path (path)' {}
</code></pre></div>
<p dir="auto">The same thing happens when using Index() explicitly. The same table specification works in SA 0.3.</p>
<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">This MAY be related to changes in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="384613818" data-permission-text="Title is private" data-url="https://github.com/sqlalchemy/sqlalchemy/issues/965" data-hovercard-type="issue" data-hovercard-url="/sqlalchemy/sqlalchemy/issues/965/hovercard" href="https://github.com/sqlalchemy/sqlalchemy/issues/965">#965</a>, however, I had to make the following change. The program worked without change with 4.0.0.  The same problem shows up in 0.4.2b, and possibly earlier versions.</p>
<p dir="auto">The traceback:</p>
<p dir="auto">File "/usr/lib/python2.3/site-packages/SQLAlchemy-0.4.2p3-py2.3.egg/sqlalchemy/orm/<strong>init</strong>.py", line 544, in mapper<br>
return Mapper(class_, local_table, *args, **params)<br>
File "/usr/lib/python2.3/site-packages/SQLAlchemy-0.4.2p3-py2.3.egg/sqlalchemy/orm/mapper.py", line 160, in <strong>init</strong><br>
self._compile_pks()<br>
File "/usr/lib/python2.3/site-packages/SQLAlchemy-0.4.2p3-py2.3.egg/sqlalchemy/orm/mapper.py", line 416, in _compile_pks<br>
if t.primary_key and pk_cols.issuperset(t.primary_key):<br>
File "/usr/lib/python2.3/sets.py", line 318, in issuperset<br>
self._binary_sanity_check(other)<br>
File "/usr/lib/python2.3/sets.py", line 343, in _binary_sanity_check<br>
raise TypeError, "Binary operation only permitted between sets"<br>
TypeError: Binary operation only permitted between sets</p>
<p dir="auto">The change will be added as a file.</p>
<hr>
<p dir="auto">Attachments: <a href="../wiki/imported_issue_attachments/957/y.patch">y.patch</a></p>