Merge branch 'boolean-normalization' of github.com:kdeldycke/cqlengine into pull-152
This commit is contained in:
2
AUTHORS
2
AUTHORS
@@ -6,5 +6,5 @@ Jon Haddad <jon@jonhaddad.com>
|
||||
CONTRIBUTORS
|
||||
|
||||
Eric Scrivner - test environment, connection pooling
|
||||
|
||||
Kevin Deldycke
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
CHANGELOG
|
||||
|
||||
0.11.0 (in progress)
|
||||
0.11.1 (in progress)
|
||||
|
||||
* Normalize and unquote boolean values.
|
||||
|
||||
0.11.0
|
||||
|
||||
* support for USING TIMESTAMP <microseconds from epoch> via a .timestamp(timedelta(seconds=30)) syntax
|
||||
- allows for long, timedelta, and datetime
|
||||
|
||||
@@ -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