marshmallow-mongoengine
marshmallow-mongoengine copied to clipboard
BinaryField assigned to wrong marshmallow field
The mongoengine validation of BinaryField makes it clear that a valid field should either be of type six.binary_type
or bson.Binary
.
However, the marshmallow-mongoengine conversion pushes mongoengine BinaryField data into the marshmallow Integer field. This causes data to be mis-cast and validation to fail, as in the example below.
from marshmallow_mongoengine import ModelSchema
from mongoengine import BinaryField, DynamicDocument
class ExampleModel(DynamicDocument):
binary_data = BinaryField(null=True)
class ExampleModelSchema(ModelSchema):
class Meta:
model = ExampleModel
Since there is no corresponding "Binary" field in marshmallow, I propose the conversion be switched from Integer field to Raw field.
Doing so seems to solve my problem: