[Sqlalchemy-tickets] Issue #4262: 3rd party dialect Type not resolved for compile (zzzeek/sqlalchem
Brought to you by:
zzzeek
From: Patrick B. <iss...@bi...> - 2018-05-21 06:45:36
|
New issue 4262: 3rd party dialect Type not resolved for compile https://bitbucket.org/zzzeek/sqlalchemy/issues/4262/3rd-party-dialect-type-not-resolved-for Patrick Buxton: A type declared in a 3rd party dialect does not get resolved when you ask it to compile and results in a: UnsupportedCompilationError: Compiler <sqlalchemy.sql.compiler.GenericTypeCompiler object at 0x0000000005C48CC0> can't render element of type <class 'sqlalchemy_hana.types.TINYINT'> ``` #!python from sqlalchemy import Table, MetaData, Column from sqlalchemy_hana.types import TINYINT meta = MetaData() t = Table('test_table', meta, Column('Col1', TINYINT)) str(t.columns['Col1'].type) ``` The problem stems from type_api _default_dialect where it's happy to lookup within the included dialects. Given that the 3rd party dialects are supposed to follow specific naming conventions, would it be possible to provide a lookup on that basis too? ``` #!python def _default_dialect(self, default): if self.__class__.__module__.startswith("sqlalchemy.dialects"): tokens = self.__class__.__module__.split(".")[0:3] mod = ".".join(tokens) return getattr(__import__(mod).dialects, tokens[-1]).dialect() else: return default.DefaultDialect() ``` |