Skip to content

autogen createindex has column objects, but then this crashes when trying to do to_index() #803

Closed

Description

@zzzeek
    @writer.rewrites(ops.CreateIndexOp)
    def create_index(context, revision, op):
        return [ops.CreateIndexOp(
            op.index_name,
            op.table_name,
            op.columns,
            schema=op.schema,
            unique=op.unique,
            postgresql_concurrently=True
        )]

leads to:

File "/home/classic/dev/alembic/alembic/autogenerate/render.py", line 88, in render_op
    lines = util.to_list(renderer(autogen_context, op))
  File "/home/classic/dev/alembic/alembic/autogenerate/render.py", line 115, in _render_modify_table
    t_lines = render_op(autogen_context, t_op)
  File "/home/classic/dev/alembic/alembic/autogenerate/render.py", line 88, in render_op
    lines = util.to_list(renderer(autogen_context, op))
  File "/home/classic/dev/alembic/alembic/autogenerate/render.py", line 229, in _add_index
    index = op.to_index()
  File "/home/classic/dev/alembic/alembic/operations/ops.py", line 808, in to_index
    idx = schema_obj.index(
  File "/home/classic/dev/alembic/alembic/operations/schemaobj.py", line 157, in index
    *[util.sqla_compat._textual_index_column(t, n) for n in columns],
  File "/home/classic/dev/alembic/alembic/operations/schemaobj.py", line 157, in <listcomp>
    *[util.sqla_compat._textual_index_column(t, n) for n in columns],
  File "/home/classic/dev/alembic/alembic/util/sqla_compat.py", line 256, in _textual_index_column
    raise ValueError("String or text() construct expected")

one side or the other has to be fixed, not sure what that's about.

Activity

  1. sqla-tester commented on Feb 26, 2021

    @sqla-tester
    Collaborator

    Mike Bayer has proposed a fix for this issue in the master branch:

    Create schema objects fresh from ops https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/2608

  2. added this to the 1.6 milestone on Feb 27, 2021
  3. zzzeek commented on Feb 27, 2021

    @zzzeek
    MemberAuthor

    this is huge and has some implications so let's start 1.6

  4. added a commit that references this issue on Apr 17, 2021
  5. added a commit that references this issue on Jun 11, 2025
    dd9c4d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions