Skip to content

Index postgresql_include renders the columns incorrectly #1258

@CaselIT

Description

@CaselIT

Describe the bug
Trying to add an index like

    sa.Index(
        "my_index",
        my_table.c.a_column,
        postgresql_include=[my_table.c.b_column],
    )

generates a migration that's not valid python, both on the upgrade and downgrade. Downgrade renders:

# upgrade
op.create_index('my_index', 'my_table', ['a_column'], unique=False, postgresql_include=[Column('b_column', Text(), table=<my_table>)])
# downgrage
op.drop_index('my_index', table_name='my_table', postgresql_include=[Column('b_column', Text(), table=<my_table>)])

Expected behavior
The postgresql_include renders correctly

To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.

import sqlalchemy as sa

my_table = sa.Table('my_table', sa.MetaData(), Column('a_column', Text()), Column('b_column', Text()))
sa.Index("my_index", my_table.c.a_column, postgresql_include=[my_table.c.b_column])

Error

See above

Versions.

  • OS: any
  • Python: any
  • Alembic: 1.10+
  • SQLAlchemy: any
  • Database: postgresql
  • DBAPI: any

Additional context

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