Open danielgafni opened 1 year ago
You need to wrap your column types in clickhouse_sqlalchemy.types.Nullable
like so:
relevance = Column(Nullable(Integer), nullable=True)
The nullable
parameter is confusing, but the docstring of the Column
constructor explicitly states this (notice the last line):
:param nullable: When set to ``False``, will cause the "NOT NULL"
phrase to be added when generating DDL for the column. When
``True``, will normally generate nothing (in SQL this defaults to
"NULL"), except in some very specific backend-specific edge cases
where "NULL" may render explicitly.
Defaults to ``True`` unless :paramref:`_schema.Column.primary_key`
is also ``True`` or the column specifies a :class:`_sql.Identity`,
in which case it defaults to ``False``.
This parameter is only used when issuing CREATE TABLE statements.
Also, per #201 , the nullable
parameter value is currently being completely ignored and does not alter CREATE TABLE statements.
Curious how we can handle nullable inserts that have default values on the table for batch inserts.
Tried ExampleTable.__table__.insert(), records....
Workaround is using add_all
Describe the bug Nullable columns don't work with:
Passing
None
with any of these types (I didn't check the others) and doingsession.add(); session.commit()
causes an error like:Enum
:Integer
:To Reproduce A rough example:
Expected behavior This should work.
Versions
clickhouse-sqlalchemy
= 0.2.0