Fixes query operations on BinaryFields

Overrides prepare_query_value in BinaryField to wrap the query value in
bson.binary.Binary. This was already done in the to_mongo call when
saving a document, but query operations required the user to convert the
value manually.

Fixes https://github.com/MongoEngine/mongoengine/issues/1127
This commit is contained in:
Freyr 2017-05-25 10:44:29 -04:00
parent 2f1fe5468e
commit 54d8c64ad5

View File

@ -1393,6 +1393,12 @@ class BinaryField(BaseField):
if self.max_bytes is not None and len(value) > self.max_bytes:
self.error('Binary value is too long')
def prepare_query_value(self, op, value):
if value is None:
return value
return super(BinaryField, self).prepare_query_value(
op, self.to_mongo(value))
class GridFSError(Exception):
pass