mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-29 04:03:44 +03:00
documentation for NullableField
This commit is contained in:
parent
9b7e7a179e
commit
3a56041da6
|
@ -22,6 +22,7 @@ Currently the following field types are supported:
|
||||||
| Enum8Field | Enum8 | Enum | See below
|
| Enum8Field | Enum8 | Enum | See below
|
||||||
| Enum16Field | Enum16 | Enum | See below
|
| Enum16Field | Enum16 | Enum | See below
|
||||||
| ArrayField | Array | list | See below
|
| ArrayField | Array | list | See below
|
||||||
|
| NullableField | Nullable | See below | See below
|
||||||
|
|
||||||
DateTimeField and Time Zones
|
DateTimeField and Time Zones
|
||||||
----------------------------
|
----------------------------
|
||||||
|
@ -103,6 +104,30 @@ Usage:
|
||||||
# created_date and username will contain a default value
|
# created_date and username will contain a default value
|
||||||
db.select('SELECT * FROM $db.event', model_class=Event)
|
db.select('SELECT * FROM $db.event', model_class=Event)
|
||||||
|
|
||||||
|
Working with nullable fields
|
||||||
|
------------------------------------------
|
||||||
|
From [some time](https://github.com/yandex/ClickHouse/pull/70) ClickHouse provides a NULL value support.
|
||||||
|
Also see some information [here](https://github.com/yandex/ClickHouse/blob/master/dbms/tests/queries/0_stateless/00395_nullable.sql).
|
||||||
|
|
||||||
|
You can create fields, that can contain any data type (except Enum)
|
||||||
|
or 'None' value, for example:
|
||||||
|
|
||||||
|
class EventData(models.Model):
|
||||||
|
|
||||||
|
date = fields.DateField()
|
||||||
|
comment = fields.NullableField(fields.StringField(), extra_null_values={''})
|
||||||
|
score = fields.NullableField(fields.UInt8Field())
|
||||||
|
serie = fields.NullableField(fields.ArrayField(fields.UInt8Field()))
|
||||||
|
|
||||||
|
engine = engines.MergeTree('date', ('date',))
|
||||||
|
|
||||||
|
|
||||||
|
score_event = EventData(date=date.today(), comment=None, score=5, serie=None)
|
||||||
|
comment_event = EventData(date=date.today(), comment='Excellent!', score=None, serie=None)
|
||||||
|
another_event = EventData(date=date.today(), comment='', score=None, serie=None)
|
||||||
|
action_event = EventData(date=date.today(), comment='', score=None, serie=[1, 2, 3])
|
||||||
|
|
||||||
|
NOTE: ArrayField of NullableField yet not supported.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user