sqlalchemy-bot / test_alembic_1

0 stars 0 forks source link

TypeError on create_index and mssql_include #516

Closed sqlalchemy-bot closed 5 years ago

sqlalchemy-bot commented 5 years ago

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 commented 5 years ago

Jimmy Thrasibule (spack) wrote:

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

sqlalchemy-bot commented 5 years ago

Michael Bayer (zzzeek) wrote:

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

sqlalchemy-bot commented 5 years ago

Michael Bayer (zzzeek) wrote:

https://gerrit.sqlalchemy.org/#/c/zzzeek/alembic/+/929

sqlalchemy-bot commented 5 years ago

Michael Bayer (zzzeek) wrote:

Check for mssql_include is None

Fixed regression caused by :ticket: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

→ 174cb4bf39ed

sqlalchemy-bot commented 5 years ago

Changes by Jimmy Thrasibule (spack):