clickhouse-sqlalchemy
clickhouse-sqlalchemy copied to clipboard
Clickhouse alembic array nullable field
Describe the bug
Auto-generated migration field on array field:
op.alter_column('accounts', 'account_state_state_init_code_methods',
existing_type=clickhouse_sqlalchemy.types.common.Array(Nullable(<class 'clickhouse_sqlalchemy.types.common.Int64'>)),
nullable=True)
To Reproduce
Add array field to models.py:
account_state_state_init_code_methods = Column(types.Array(types.Nullable(types.Int64)), default=None, nullable=True)
Expected behavior
op.alter_column('accounts', 'account_state_state_init_code_methods',
existing_type=clickhouse_sqlalchemy.types.common.Array(Nullable(clickhouse_sqlalchemy.types.common.Int64)),
nullable=True)
Try Column(types.Array(types.Nullable(types.Int64()))
in model definition.
WOW! Thanks! this did a trick!!!
Your work is awesome :heart:
Nah, after second migration it fails one more time in existing_type=
field:
op.alter_column('accounts', 'account_state_state_init_code_methods',
existing_type=clickhouse_sqlalchemy.types.common.Array(Nullable(<class 'clickhouse_sqlalchemy.types.common.Int64'>)),
nullable=True)
(first migration works)
BTW I got strange stuff after running alembic revision --autogenerate
right after first migration without any changes:
INFO [alembic.autogenerate.compare] Detected NULL on column 'transactions.out_msg_value_grams'
INFO [alembic.autogenerate.compare] Detected NULL on column 'transactions.out_msg_body'
...
I see Nullable(T) columns generation via Column(..., nullable=True) is not supported.
in Limitations
, but I don't use nullable=True
, just Nullable(T)
. This isn't supported too?
This is complicated. Currently Nullable(T)
and nullable=True
duplicate each other and produce a big mess. I suppose they both not supported. :)