Fix calling of custom type compare function

Merged
#4 · Created  · Last updated

Merged pull request

Merged in mvschaik/alembic/fix_custom_compare_type (pull request #4)

6732070·Author: ·Closed by: ·2013-08-28

Description

When using a custom comparison function for compare_type, the calling code crashes. This issue was introduced in 949367b.

Steps to reproduce:

def my_compare_type(context, inspected_column, metadata_column, inspected_type, metadata_type): pass context.configure(connection=connection, target_metadata=target_metadata, compare_type=my_compare_type)
... File "alembic/env.py", line 74, in run_migrations_online context.run_migrations() File "<string>", line 7, in run_migrations File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/environment.py", line 652, in run_migrations self.get_context().run_migrations(**kw) File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/migration.py", line 209, in run_migrations self): File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/command.py", line 83, in retrieve_migrations autogen._produce_migration_diffs(context, template_args, imports) File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/autogenerate.py", line 143, in _produce_migration_diffs autogen_context, object_filters, include_schemas) File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/autogenerate.py", line 205, in _produce_net_changes inspector, metadata, diffs, autogen_context) File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/autogenerate.py", line 249, in _compare_tables diffs, autogen_context) File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/autogenerate.py", line 299, in _compare_columns col_diff, autogen_context File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/autogenerate.py", line 349, in _compare_type isdiff = autogen_context['context']._compare_type(conn_col, metadata_col) File "/.../python2.7/site-packages/alembic-0.6.1dev-py2.7.egg/alembic/migration.py", line 283, in _compare_type inspector_column['type'], File "/.../python2.7/site-packages/sqlalchemy/sql/operators.py", line 320, in __getitem__ return self.operate(getitem, index) File "/.../python2.7/site-packages/sqlalchemy/sql/expression.py", line 2300, in operate return op(self.comparator, *other, **kwargs) File "/.../python2.7/site-packages/sqlalchemy/sql/operators.py", line 320, in __getitem__ return self.operate(getitem, index) File "/.../python2.7/site-packages/sqlalchemy/sql/expression.py", line 1986, in operate return o[0](self, self.expr, op, *(other + o[1:]), **kwargs) File "/.../python2.7/site-packages/sqlalchemy/sql/expression.py", line 2137, in _unsupported_impl "this expression" % op.__name__) NotImplementedError: Operator 'getitem' is not supported on this expression

0 attachments

0 comments

Loading commits...