Issues

Issue #99 resolved

autogenerate crashes when key attribute is used on Column

James Iseppi
created an issue

A model with a Column like: filename = sa.Column(sa.types.Text, key='_filename', nullable=False) Will cause alembic revision --autogenerate to crash with the following traceback:

Traceback (most recent call last): File "/home/james/zookeepr/env/bin/alembic", line 9, in <module> load_entry_point('alembic==0.4.1', 'console_scripts', 'alembic')() File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/config.py", line 255, in main CommandLine(prog=prog).main(argv=argv) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/config.py", line 250, in main self.run_cmd(cfg, options) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/config.py", line 241, in run_cmd dict((k, getattr(options, k)) for k in kwarg) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/command.py", line 97, in revision script.run_env() File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/script.py", line 191, in run_env util.load_python_file(self.dir, 'env.py') File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/util.py", line 185, in load_python_file module = imp.load_source(module_id, path, open(path, 'rb')) File "alembic/env.py", line 71, in <module> run_migrations_online() File "alembic/env.py", line 64, in run_migrations_online context.run_migrations() File "<string>", line 7, in run_migrations File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/environment.py", line 494, in run_migrations self.get_context().run_migrations(kw) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/migration.py", line 200, in run_migrations self): File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/command.py", line 83, in retrieve_migrations autogen._produce_migration_diffs(context, template_args, imports) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/autogenerate.py", line 127, in _produce_migration_diffs include_schemas) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/autogenerate.py", line 188, in _produce_net_changes inspector, metadata, diffs, autogen_context) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/autogenerate.py", line 224, in _compare_tables diffs, autogen_context) File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/alembic-0.4.1-py2.7.egg/alembic/autogenerate.py", line 259, in _compare_columns metadata_col = metadata_table.c[colname] File "/home/james/zookeepr/env/local/lib/python2.7/site-packages/sqlalchemy/util/_collections.py", line 88, in getitem return self._data[key] KeyError: u'filename'