From b2cf8f42451cb70c997b551678527f94b22947c0 Mon Sep 17 00:00:00 2001 From: Itai Shirav Date: Thu, 29 Sep 2016 11:24:22 +0300 Subject: [PATCH] Fixes by tsionyx --- README.rst | 4 ++-- src/infi/clickhouse_orm/fields.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 27f2d07..f093d52 100644 --- a/README.rst +++ b/README.rst @@ -228,8 +228,8 @@ You can create array fields containing any data type, for example:: class SensorData(models.Model): date = fields.DateField() - temperatures = fields.ArrayField(fields.Float32Field) - humidity_levels = fields.ArrayField(fields.UInt8Field) + temperatures = fields.ArrayField(fields.Float32Field()) + humidity_levels = fields.ArrayField(fields.UInt8Field()) engine = engines.MergeTree('date', ('date',)) diff --git a/src/infi/clickhouse_orm/fields.py b/src/infi/clickhouse_orm/fields.py index 0406b01..fb4dab5 100644 --- a/src/infi/clickhouse_orm/fields.py +++ b/src/infi/clickhouse_orm/fields.py @@ -107,6 +107,8 @@ class DateTimeField(Field): if isinstance(value, int): return datetime.datetime.fromtimestamp(value, pytz.utc) if isinstance(value, string_types): + if value == '0000-00-00 00:00:00': + return self.class_default return datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S') raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))