crate / sqlalchemy-cratedb

SQLAlchemy dialect for CrateDB.
https://cratedb.com/docs/sqlalchemy-cratedb/
Apache License 2.0
3 stars 2 forks source link

SqlAlchemy unable to map cratedb long and double data types. #124

Closed AKNiazi closed 6 years ago

AKNiazi commented 6 years ago

I want to create new table in cratedb with one column of type long and other of type double using Sqlalchemy. I mapped long and double data types to Sqlalchemy's NUMERIC and DECIMAL data types as stated here. But they are not getting converted to long and double. Following is my code snippet.

     meta = MetaData(self.get_sqla_engine())
     Table('user', metadata,
         Column('id', Integer, primary_key=True),
         Column('user_name', String(), nullable=False),
         Column('num', DECIMAL(), nullable=False),
         Column('num2', NUMERIC(), nullable=False)
     )

     table = Table(datasource, meta, *columns)
     meta.create_all()

The sql query it creates is

     CREATE TABLE user (
             id INT, 
             user_name STRING,
             num DECIMAL,
             num2 NUMERIC, 
        PRIMARY KEY (id)
   );

As numeric and decimal are not supported cratedb types, cratedb throws error.

matriv commented 6 years ago

Issue has been fixed and released with 0.21.1