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

TypeError on create_index and mssql_include #516

Closed
sqlalchemy-bot opened this issue Nov 14, 2018 · 6 comments
Closed

TypeError on create_index and mssql_include #516

sqlalchemy-bot opened this issue Nov 14, 2018 · 6 comments
Labels
bug Something isn't working op directives

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Jimmy Thrasibule (@spack)

Using MSSQL Express 2017 and pymssql, a TypeError is raised during schema upgrade when creating an index.

alembic==1.0.2
pymssql==2.1.4
def upgrade():
    op.create_table('table',
    [...]
    sa.Column('col', sa.Unicode(length=13), nullable=False),
    [...]
    )
    op.create_index(op.f('ix_table_col'), 'col', ['col'], unique=False
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/bin/inv", line 11, in <module>
    sys.exit(program.run())
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/invoke/program.py", line 363, in run
    self.execute()
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/invoke/program.py", line 532, in execute
    executor.execute(*self.tasks)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/invoke/executor.py", line 129, in execute
    result = call.task(*args, **call.kwargs)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/invoke/tasks.py", line 128, in __call__
    result = self.body(*args, **kwargs)
  File "/home/user/scap/tasks/db.py", line 60, in upgrade
    command.upgrade(cfg, revision)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/command.py", line 254, in upgrade
    script.run_env()
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/script/base.py", line 427, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
    module = load_module_py(module_id, path)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/util/compat.py", line 82, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/project/lib/alembic/env.py", line 72, in <module>
    run_migrations_online()
  File "/home/user/project/lib/alembic/env.py", line 66, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/runtime/environment.py", line 836, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/runtime/migration.py", line 330, in run_migrations
    step.migration_fn(**kw)
  File "/home/user/project/lib/alembic/versions/6e9beb929668_test.py", line 46, in upgrade
    op.create_index(op.f('ix_table_col'), 'col', ['col'], unique=False)
  File "<string>", line 8, in create_index
  File "<string>", line 3, in create_index
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/operations/ops.py", line 857, in create_index
    return operations.invoke(op)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/operations/base.py", line 319, in invoke
    return fn(self, operation)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/operations/toimpl.py", line 88, in create_index
    operations.impl.create_index(idx)
  File "/home/user/.local/share/virtualenvs/project-TS2Ah8Sl/lib/python3.6/site-packages/alembic/ddl/mssql.py", line 94, in create_index
    for col in mssql_include:
TypeError: 'NoneType' object is not iterable
@sqlalchemy-bot
Copy link
Author

Changes by Jimmy Thrasibule (@spack):

  • edited description

@sqlalchemy-bot
Copy link
Author

Jimmy Thrasibule (@spack) wrote:

Note that if I go back to alembic 1.0.1 it works.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

oh, we just added this, OK, then it's a quick regression.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

Check for mssql_include is None

Fixed regression caused by 🎫513, where the logic to consume
mssql_include was not correctly interpreting the case where the flag
was not present, breaking the op.create_index directive for SQL Server
as a whole.

Change-Id: I4c3a9d1f12017b62a7affa3863bba6e2bead67cf
Fixes: #516

174cb4b

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added op directives bug Something isn't working labels Nov 27, 2018
vvvrrooomm pushed a commit to vvvrrooomm/alembic that referenced this issue Jan 10, 2019
Fixed regression caused by 🎫`513`, where the logic to consume
``mssql_include`` was not correctly interpreting the case where the flag
was not present, breaking the ``op.create_index`` directive for SQL Server
as a whole.

Change-Id: I4c3a9d1f12017b62a7affa3863bba6e2bead67cf
Fixes: sqlalchemy#516
vvvrrooomm pushed a commit to vvvrrooomm/alembic that referenced this issue Jan 10, 2019
Fixed regression caused by 🎫`513`, where the logic to consume
``mssql_include`` was not correctly interpreting the case where the flag
was not present, breaking the ``op.create_index`` directive for SQL Server
as a whole.

Change-Id: I4c3a9d1f12017b62a7affa3863bba6e2bead67cf
Fixes: sqlalchemy#516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working op directives
Projects
None yet
Development

No branches or pull requests

1 participant