mikeywaites / kim

Kim: A JSON Serialization and Marshaling framework
http://kim.readthedocs.org/en/latest/
Other
317 stars 17 forks source link

field.Boolean doesn't convert 'truthy' strings to boolen #96

Closed mikeywaites closed 7 years ago

mikeywaites commented 8 years ago

field.Boolean should handle any 'truthy' value and when permitted, should process the value into its boolean value. IE when a string is set the field.Boolean should return True

class MyMapper(Mapper):
     activated = field.Boolean()

# scalar_sub_select will return an id which is a string rather than a Boolean scalar type.
>>> obj = query(Model, scalar_sub_select.label('activated')).first()

>>> MyMapper(obj=obj).serialize(objs)
>>> {'activated': 'asdasdsd'}
mikeywaites commented 7 years ago

I believe this ticket it outdated now. The BooleanFieldOpts accepts a list of values that denote wether the value on session.data should be considered true or not.