Skip to content

Commit

Permalink
Guess number or _reflect_table alembic args xzkostyan#249
Browse files Browse the repository at this point in the history
  • Loading branch information
xzkostyan committed Oct 8, 2023
1 parent 16ff72f commit a3140a9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion clickhouse_sqlalchemy/alembic/comparators.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging

from alembic import __version__ as alembic_version
from alembic.autogenerate import comparators
from alembic.autogenerate.compare import _compare_columns
from alembic.operations.ops import ModifyTableOps
from alembic.util.sqla_compat import _reflect_table
from alembic.util.sqla_compat import _reflect_table as _alembic_reflect_table
from sqlalchemy import schema as sa_schema
from sqlalchemy import text

Expand All @@ -12,6 +13,10 @@

logger = logging.getLogger(__name__)

alembic_version = tuple(
(int(x) if x.isdigit() else x) for x in alembic_version.split('.')
)


def _extract_to_table_name(create_table_query):
query = create_table_query
Expand All @@ -29,6 +34,13 @@ def _extract_to_table_name(create_table_query):
comparators.dispatch_for('schema', 'clickhouse')(default_comparator)


def _reflect_table(inspector, table):
if alembic_version >= (1, 11, 0):
return _alembic_reflect_table(inspector, table)
else:
return _alembic_reflect_table(inspector, table)


@comparators.dispatch_for('schema', 'clickhouse')
def compare_mat_view(autogen_context, upgrade_ops, schemas):
connection = autogen_context.connection
Expand Down

0 comments on commit a3140a9

Please sign in to comment.