Skip to content

ExecuteSQLOp rendering does not respect alembic_module_prefix #1656

@biggerfisch

Description

@biggerfisch

Describe the bug

Rendering ExecuteSQLOp does not respect the alembic_module_prefix setting.
This is due to op. being hard-coded in render.py.

Expected behavior

Rendering ExecuteSQLOp to respect alembic_module_prefix.

To Reproduce

The entire context is hard to do minimally due to ExecuteSQLOp not really being autogenerated by normal code. This is an approximation as the bug is quite direct in the code.

context.configure(alembic_module_prefix="test_op")

...
def process_revision_directives(context, revision, directives):
    directive.ops = [ops.ExecuteSQLOp(sqltext="COMMIT")]

Error

Generated SQL is

op.execute('COMMIT')

Should be

test_op.execute('COMMIT')

Versions.

  • OS: macOS
  • Python: 3.10
  • Alembic: 1.15.2
  • SQLAlchemy: 2.0.40
  • Database: PostgreSQL
  • DBAPI:

Additional context

I have a fix ready to go, I think! Will fill a PR attached to this issue :)

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