Issues

Issue #26 resolved

Missing 'autogen_context' param in alembic.autogenerate._render_check_constraint.

Stefano Fontanelli
created an issue

I got the error below when I try to run:

{{{ alembic revision --autogenerate -m "test" }}}

{{{ INFO [alembic.migration] Context impl MySQLImpl. INFO [alembic.migration] Will assume non-transactional DDL. INFO [alembic.autogenerate] Detected added table 'files' INFO [alembic.autogenerate] Detected added table 'node_infos_linksnode_infos' INFO [alembic.autogenerate] Detected added table 'node_infos_imagesfiles' INFO [alembic.autogenerate] Detected added table 'users' INFO [alembic.autogenerate] Detected added table 'node_infos_keywords' INFO [alembic.autogenerate] Detected added table 'settings' INFO [alembic.autogenerate] Detected added table 'node_infos' INFO [alembic.autogenerate] Detected added table 'node_infos_filesfiles' INFO [alembic.autogenerate] Detected added table 'users_groups' INFO [alembic.autogenerate] Detected added table 'languages' INFO [alembic.autogenerate] Detected added table 'themes' INFO [alembic.autogenerate] Detected added table 'groups' INFO [alembic.autogenerate] Detected added table 'nodes_bannersfiles' INFO [alembic.autogenerate] Detected added table 'keywords' INFO [alembic.autogenerate] Detected added table 'nodes' INFO [alembic.autogenerate] Detected added table 'views' INFO [alembic.autogenerate] Detected added table 'views_descriptions' INFO [alembic.autogenerate] Detected added table 'setting_types' Traceback (most recent call last): File "/home/stefano/projects/aybu-1.0/bin/alembic", line 9, in <module> load_entry_point('alembic==0.2.0', 'console_scripts', 'alembic')() File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/config.py", line 228, in main dict((k, getattr(options, k)) for k in kwarg) File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/command.py", line 81, in revision script.run_env() File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/script.py", line 123, in run_env util.load_python_file(self.dir, 'env.py') File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/util.py", line 149, in load_python_file module = imp.load_source(module_id, path, open(path, 'rb')) File "alembic/env.py", line 76, in <module> run_migrations_online() File "alembic/env.py", line 69, in run_migrations_online context.run_migrations() File "<string>", line 3, in run_migrations File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/environment.py", line 384, in run_migrations self.get_context().run_migrations(kw) File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/migration.py", line 153, in run_migrations self): File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/command.py", line 73, in retrieve_migrations autogen.produce_migration_diffs(context, template_args, imports) File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/autogenerate.py", line 37, in produce_migration_diffs _indent(_produce_upgrade_commands(diffs, autogen_context)) File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/autogenerate.py", line 231, in _produce_upgrade_commands buf.append(_invoke_command("upgrade", diff, autogen_context)) File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/autogenerate.py", line 246, in _invoke_command return _invoke_adddrop_command(updown, args, autogen_context) File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/autogenerate.py", line 268, in _invoke_adddrop_command return cmd_callables1 File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/autogenerate.py", line 313, in _add_table table.constraints] File "/home/stefano/projects/aybu-1.0/local/lib/python2.7/site-packages/alembic/autogenerate.py", line 427, in _render_constraint return renderer(constraint, autogen_context) TypeError: _render_check_constraint() takes exactly 1 argument (2 given) }}}

I checked the code: missing 'autogen_context' param in alembic.autogenerate._render_check_constraint. {{{ def _render_check_constraint(constraint): opts = [] if constraint.name: opts.append(("name", repr(constraint.name))) return "%(prefix)sCheckConstraint('TODO')" % { "prefix":_sqlalchemy_autogenerate_prefix(autogen_context) }

}}}

I attached a patch which adds the missing parameter in the function signature.

{{{ def _render_check_constraint(constraint, autogen_context): opts = [] if constraint.name: opts.append(("name", repr(constraint.name))) return "%(prefix)sCheckConstraint('TODO')" % { "prefix":_sqlalchemy_autogenerate_prefix(autogen_context) } }}}

Comments (2)

  1. Log in to comment