Skip to content

DropIndexOp does not render keyword arguments such as postgresql_concurrently #849

@jetzhou

Description

@jetzhou

Describe the bug
1011366 added kwargs support to drop index operation in SQL generation. However, in autogenerate render step, an operation such as this one:

alembic.operations.ops.DropIndexOp(
    'example_index',
    postgresql_concurrently=True,
)

will be rendered to

op.drop_index(op.f('example_index'))

which ignores the postgresql_concurrently kwarg.

Expected behavior

alembic.operations.ops.DropIndexOp(
    'example_index',
    postgresql_concurrently=True,
)

should render in autogenerate to

op.drop_index(op.f('example_index'), postgresql_concurrently=True)

To Reproduce
Test code that does not pass

    def test_render_drop_index_custom_kwarg(self):
        t = Table(
            "test",
            MetaData(),
            Column("id", Integer, primary_key=True),
            Column("active", Boolean()),
            Column("code", String(255)),
        )
        idx = Index(None, t.c.active, t.c.code, somedialect_foobar="option")
        op_obj = ops.DropIndexOp.from_index(idx)
        eq_ignore_whitespace(
            autogenerate.render_op_text(self.autogen_context, op_obj),
            "op.drop_index(op.f('ix_test_active'), table_name='test', "
            "somedialect_foobar='option')",
        )

Versions.

  • OS: Ubuntu 21.04
  • Python: 3.9.5
  • Alembic: 1.6.4
  • SQLAlchemy: 1.3.19
  • Database: PostgreSQL
  • DBAPI: psycopg

Additional context
Proposed fix: jetzhou@6392a28

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions