mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-08-02 03:00:09 +03:00
fix: check default value existence if field value is None
This commit is contained in:
parent
45a9200ff6
commit
913a1635d1
|
@ -142,6 +142,8 @@ class StringField(Field):
|
||||||
return value
|
return value
|
||||||
if isinstance(value, bytes):
|
if isinstance(value, bytes):
|
||||||
return value.decode('UTF-8')
|
return value.decode('UTF-8')
|
||||||
|
if value is None and self.default is not None:
|
||||||
|
return self.default
|
||||||
raise ValueError('Invalid value for %s: %r' % (self.__class__.__name__, value))
|
raise ValueError('Invalid value for %s: %r' % (self.__class__.__name__, value))
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,6 +297,8 @@ class BaseIntField(Field):
|
||||||
'''
|
'''
|
||||||
def to_python(self, value, timezone_in_use):
|
def to_python(self, value, timezone_in_use):
|
||||||
try:
|
try:
|
||||||
|
if value is None and self.default is not None:
|
||||||
|
return int(self.default)
|
||||||
return int(value)
|
return int(value)
|
||||||
except:
|
except:
|
||||||
raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))
|
raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))
|
||||||
|
@ -371,6 +375,8 @@ class BaseFloatField(Field):
|
||||||
|
|
||||||
def to_python(self, value, timezone_in_use):
|
def to_python(self, value, timezone_in_use):
|
||||||
try:
|
try:
|
||||||
|
if value is None and self.default is not None:
|
||||||
|
return float(self.default)
|
||||||
return float(value)
|
return float(value)
|
||||||
except:
|
except:
|
||||||
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