diff --git a/src/infi/clickhouse_orm/fields.py b/src/infi/clickhouse_orm/fields.py index 2829910..44e833a 100644 --- a/src/infi/clickhouse_orm/fields.py +++ b/src/infi/clickhouse_orm/fields.py @@ -108,11 +108,10 @@ 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) - raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value)) + except: + raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value)) def validate(self, value): self._range_check(value, self.min_value, self.max_value) @@ -177,11 +176,10 @@ 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) - raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value)) + except: + raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value)) class Float32Field(BaseFloatField):