Infinidat/infi.clickhouse_orm

Cannot add new alias field with type Decimal64Field

Opened this issue · 1 comments

Hi!

After migration I can find the new field with type Decimal64Field, but it is not alias. For example:

# model from tests/test_migrations.py
class AliasModel1(Model):
    date = DateField()
    date_alias = DateField(alias='date')
    int_field = Int8Field()
    int_field_plus_one = Int8Field(alias='int_field + 1')

    # this is new field with alias expression
    dec = Decimal64Field(6, alias='toDecimal64(int_field, 6) / 10')

    engine = MergeTree('date', ('date',))

    @classmethod
    def table_name(cls):
        return 'alias_date'

After migration this model has dec field but it is not alias.

First it creates correctly field here, but then it checks types and compares Decimal64(6) with Decimal(18, 6) and alters it again.

I've tried to change Decimal64Field(6) to DecimalField(18, 6) but it didn't help, because DecimalField has db_type = Decimal(18,6) (no space) and clickhouse returns type Decimal(18, 6)