mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-25 10:13:45 +03:00
Simplify conversion of int and float fields
This commit is contained in:
parent
4efdcda97b
commit
a3bd212133
|
@ -108,10 +108,9 @@ class DateTimeField(Field):
|
|||
class BaseIntField(Field):
|
||||
|
||||
def to_python(self, value):
|
||||
if isinstance(value, int):
|
||||
return value
|
||||
if isinstance(value, basestring):
|
||||
try:
|
||||
return int(value)
|
||||
except:
|
||||
raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))
|
||||
|
||||
def validate(self, value):
|
||||
|
@ -177,10 +176,9 @@ class Int64Field(BaseIntField):
|
|||
class BaseFloatField(Field):
|
||||
|
||||
def to_python(self, value):
|
||||
if isinstance(value, float):
|
||||
return value
|
||||
if isinstance(value, basestring) or isinstance(value, int):
|
||||
try:
|
||||
return float(value)
|
||||
except:
|
||||
raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user