mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 09:06:41 +03:00
Fixes by tsionyx
This commit is contained in:
parent
685e3dffe9
commit
b2cf8f4245
|
@ -228,8 +228,8 @@ You can create array fields containing any data type, for example::
|
||||||
class SensorData(models.Model):
|
class SensorData(models.Model):
|
||||||
|
|
||||||
date = fields.DateField()
|
date = fields.DateField()
|
||||||
temperatures = fields.ArrayField(fields.Float32Field)
|
temperatures = fields.ArrayField(fields.Float32Field())
|
||||||
humidity_levels = fields.ArrayField(fields.UInt8Field)
|
humidity_levels = fields.ArrayField(fields.UInt8Field())
|
||||||
|
|
||||||
engine = engines.MergeTree('date', ('date',))
|
engine = engines.MergeTree('date', ('date',))
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,8 @@ class DateTimeField(Field):
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
return datetime.datetime.fromtimestamp(value, pytz.utc)
|
return datetime.datetime.fromtimestamp(value, pytz.utc)
|
||||||
if isinstance(value, string_types):
|
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')
|
return datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
|
||||||
raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))
|
raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user