Skip to content

Alembic keeps detecting JSON change #968

@WilliamDEdwards

Description

@WilliamDEdwards

Describe the bug

MariaDB's JSON type is an alias for LONGTEXT with a JSON_VALID check. When defining a column of type sqlalchemy.dialects.mysql.JSON, Alembic keeps generating a migration of existing_type=mysql.LONGTEXT(charset='utf8mb4', collation='utf8mb4_bin') to type_=mysql.JSON().

Expected behavior

I would expect Alembic to not detect any changes between LONGTEXT with JSON_VALID check and sqlalchemy.dialects.mysql.JSON.

To Reproduce

  • Add an sqlalchemy.dialects.mysql.JSON column
  • Create a migration & upgrade
  • Create another migration. This will cause another migration with an operation like the one below to be created.
op.alter_column('api_users', 'trusted_ip_networks',
    existing_type=mysql.LONGTEXT(charset='utf8mb4', collation='utf8mb4_bin'),
    type_=mysql.JSON(),
    existing_nullable=False,
    existing_server_default=sa.text("'[]'")
)

Error

None.

Versions.

  • OS: macOS 11.6
  • Python: 3.8.9
  • Alembic: 1.4.2
  • SQLAlchemy: 1.3.16
  • Database: MariaDB 10.5.9
  • DBAPI: -

Additional context

None.

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