Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alembic keeps detecting JSON change #968

Closed
WilliamDEdwards opened this issue Nov 12, 2021 · 1 comment
Closed

Alembic keeps detecting JSON change #968

WilliamDEdwards opened this issue Nov 12, 2021 · 1 comment
Labels

Comments

@WilliamDEdwards
Copy link

WilliamDEdwards commented Nov 12, 2021

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.

@WilliamDEdwards WilliamDEdwards added the requires triage New issue that requires categorization label Nov 12, 2021
@sqla-tester
Copy link
Collaborator

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

add type synonym for mysql.LONGTEXT / JSON https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/3306

@zzzeek zzzeek added autogenerate - detection bug Something isn't working mysql and removed requires triage New issue that requires categorization labels Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants