See the example dialect at:

https://gerrit.sqlalchemy.org/#/c/zzzeek/alembic/+/755/3/tests/test_external_dialect.py

for how you can do this, with this patch.   As always, I'm looking to
know that this patch does everything you need before merging.





On Fri, May 18, 2018 at 9:13 AM, Mike Bayer <mike...@zzzcomputing.com> wrote:
> On Fri, May 18, 2018 at 7:17 AM, Антонио Антуан <a.ch....@gmail.com> wrote:
>> Hi.
>> I use [that](https://github.com/xzkostyan/clickhouse-sqlalchemy) library and
>> tries to make migrations using alembic.
>>
>> Here is simple implementation for that dialect:
>> ```
>> class ClickHOuseImpl(postgresql.PostgresqlImpl):
>>     __dialect__ = 'clickhouse'
>>     transactional_ddl = False
>
> https://bitbucket.org/zzzeek/alembic/issues/494/_repr_type-conflates-setting-up-imports
> is added since it makes no sense to generate impl_rt then ignore it.
>
>
>
>> ```
>>
>> Here is what I got after running `alembic init`:
>> ```
>> op.create_table('order_logs',
>>     sa.Column('ts_spawn', clickhouse_sqlalchemy.types.UInt32(),
>> nullable=False),
>>     sa.Column('platform_id', clickhouse_sqlalchemy.types.UInt32(),
>> nullable=False),
>>     sa.Column('slave_prefix', clickhouse_sqlalchemy.types.String(),
>> nullable=False),
>>     sa.Column('int_orders_ids', clickhouse_sqlalchemy.types.Array(<class
>> 'clickhouse_sqlalchemy.types.UInt32'>), nullable=False),
>>     sa.Column('state', clickhouse_sqlalchemy.types.UInt8(), nullable=False),
>>     sa.Column('step', clickhouse_sqlalchemy.types.UInt8(), nullable=False),
>>     sa.Column('ext_orders_ids', clickhouse_sqlalchemy.types.Array(<class
>> 'clickhouse_sqlalchemy.types.String'>), nullable=True),
>>     sa.Column('url', clickhouse_sqlalchemy.types.String(), nullable=True),
>>     sa.Column('request', clickhouse_sqlalchemy.types.String(),
>> nullable=True),
>>     sa.Column('response', clickhouse_sqlalchemy.types.String(),
>> nullable=True),
>>     sa.PrimaryKeyConstraint('ts_spawn', 'platform_id', 'slave_prefix',
>> 'int_orders_ids', 'state', 'step')
>>     )
>> ```
>> As you can see array-elements generated not correct: nested types have
>> `<class...>` substring.
>>
>> `alembic.autogenerate.render._repr_type` shows me, that custom
>> representation of types uses only if module_name startswith
>> `sqlalchemy.dialects`:
>> ```
>> ...
>>     if hasattr(autogen_context.migration_context, 'impl'):
>>         impl_rt = autogen_context.migration_context.impl.render_type(
>>             type_, autogen_context)
>>     else:
>>         impl_rt = None
>>
>>     mod = type(type_).__module__
>>     imports = autogen_context.imports
>>     if mod.startswith("sqlalchemy.dialects"):
>>         dname = re.match(r"sqlalchemy\.dialects\.(\w+)", mod).group(1)
>>         if imports is not None:
>>             imports.add("from sqlalchemy.dialects import %s" % dname)
>>         if impl_rt:
>>             return impl_rt
>> ...
>> ```
>>
>> Is there any ways to fix the problem?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sqlalchemy-alembic" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sqlalchemy-alembic+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to