Skip to content

check does not work with ExecuteSQLOp present #1335

Description

@CaselIT

Discussed in #1334

Originally posted by BayerSe October 23, 2023
Hi,

we're using ExecuteSQLOp to add triggers to some columns.

With these added, alembic check nowadays raises a not implemented error, it seems as if because ExecuteSQLOp does not implement .to_diff_tuple().

op = ops.ExecuteSQLOp(sqltext='CREATE OR REPLACE TRIGGER ...')
op.to_diff_tuple()  # NotImplementedError

This used to work in version 1.6.5 and I think this error was introduced in 1.7.0 when .to_diff_tuple() was added to the base class MigrateOperation, see here.

Here's the stacktrace of alembic check:

INFO  [alembic.runtime.migration] Context impl OracleImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.autogenerate.compare] Detected added table 'his_test'
Traceback (most recent call last):
  File "/home/user/PycharmProjects/project/.venv/bin/alembic", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/user/PycharmProjects/project/.venv/lib/python3.11/site-packages/alembic/config.py", line 630, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/home/user/PycharmProjects/project/.venv/lib/python3.11/site-packages/alembic/config.py", line 624, in main
    self.run_cmd(cfg, options)
  File "/home/user/PycharmProjects/project/.venv/lib/python3.11/site-packages/alembic/config.py", line 601, in run_cmd
    fn(
  File "/home/user/PycharmProjects/project/.venv/lib/python3.11/site-packages/alembic/command.py", line 294, in check
    diffs = migration_script.upgrade_ops.as_diffs()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/PycharmProjects/project/.venv/lib/python3.11/site-packages/alembic/operations/ops.py", line 2556, in as_diffs
    return list(OpContainer._ops_as_diffs(self))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/PycharmProjects/project/.venv/lib/python3.11/site-packages/alembic/operations/ops.py", line 2566, in _ops_as_diffs
    yield op.to_diff_tuple()
          ^^^^^^^^^^^^^^^^^^
  File "/home/user/PycharmProjects/project/.venv/lib/python3.11/site-packages/alembic/operations/ops.py", line 88, in to_diff_tuple
    raise NotImplementedError
NotImplementedError

I have no idea how this worked in 1.6.5 as already there, ExecuteSQLOp and some other ops did not have .to_diff_tuple(), but with .to_diff_tuple() in the base class check does not work as of today.

Thanks
Sebastian

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