SAP / sqlalchemy-hana

SQLAlchemy Dialect for SAP HANA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TINYINT does not compile correctly

sambu16 opened this issue · comments

The code below seems to give an error and I can't figure out why myself. I wondered if you perhaps have any insights? It looks like it should run the "visit_TINYINT" method but somehow does not.

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)

UnsupportedCompilationError: Compiler <sqlalchemy.sql.compiler.GenericTypeCompiler object at 0x0000000005C48CC0> can't render element of type <class 'sqlalchemy_hana.types.TINYINT'>

I think this might be more of a sqlalchemy issue itself, unless the dialect module name starts with 'sqlachemy.dialects', it won't look up the dialect with which to compile the type. I'll maybe pose the question to Mike himself

from type_api.py

    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()