Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sqlalchemy-bot opened this issue Jan 31, 2012 · 3 comments
Labels
bug Something isn't working high priority

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Stefano (@stefanofontanelli)

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_links__node_infos'
INFO  [alembic.autogenerate] Detected added table 'node_infos_images__files'
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_files__files'
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_banners__files'
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_callables[1](*cmd_args)
  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)
        }

Attachments: fix_render_check_constraint.patch

@sqlalchemy-bot
Copy link
Author

Changes by Stefano (@stefanofontanelli):

  • added labels: high priority

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

thanks for the patch, that is [[https://bitbucket.org/zzzeek/alembic/changeset/e1fde1031ddbc0ee3bdd38082a14542881be3db5|e1fde1031ddbc0ee3bdd38082a14542881be3db5]], I'll put a release out.

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added high priority bug Something isn't working labels Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

1 participant