Merge branch 'boolean-normalization' of github.com:kdeldycke/cqlengine into pull-152
This commit is contained in:
@@ -442,11 +442,17 @@ class Boolean(Column):
|
||||
def __str__(self):
|
||||
return 'true' if self.value else 'false'
|
||||
|
||||
def to_python(self, value):
|
||||
def validate(self, value):
|
||||
""" Always returns a Python boolean. """
|
||||
if isinstance(value, self.Quoter):
|
||||
value = value.value
|
||||
return bool(value)
|
||||
|
||||
def to_python(self, value):
|
||||
return self.validate(value)
|
||||
|
||||
def to_database(self, value):
|
||||
return self.Quoter(bool(value))
|
||||
return self.Quoter(self.validate(value))
|
||||
|
||||
|
||||
class Float(Column):
|
||||
|
||||
@@ -144,6 +144,19 @@ class TestBooleanIO(BaseColumnIOTest):
|
||||
pkey_val = True
|
||||
data_val = False
|
||||
|
||||
def comparator_converter(self, val):
|
||||
return val.value if isinstance(val, columns.Boolean.Quoter) else val
|
||||
|
||||
class TestBooleanQuoter(BaseColumnIOTest):
|
||||
|
||||
column = columns.Boolean
|
||||
|
||||
pkey_val = True
|
||||
data_val = columns.Boolean.Quoter(False)
|
||||
|
||||
def comparator_converter(self, val):
|
||||
return val.value if isinstance(val, columns.Boolean.Quoter) else val
|
||||
|
||||
class TestFloatIO(BaseColumnIOTest):
|
||||
|
||||
column = columns.Float
|
||||
|
||||
Reference in New Issue
Block a user