BinaryField returns str not unicode
This commit is contained in:
parent
3c7e8be2e7
commit
edfda6ad5b
@ -505,10 +505,11 @@ class BinaryField(BaseField):
|
|||||||
return pymongo.binary.Binary(value)
|
return pymongo.binary.Binary(value)
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
return unicode(value)
|
# Returns str not unicode as this is binary data
|
||||||
|
return str(value)
|
||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
assert isinstance(value, str)
|
assert isinstance(value, str)
|
||||||
|
|
||||||
if self.max_bytes is not None and len(value) > self.max_bytes:
|
if self.max_bytes is not None and len(value) > self.max_bytes:
|
||||||
raise ValidationError('Binary value is too long')
|
raise ValidationError('Binary value is too long')
|
||||||
|
@ -918,7 +918,7 @@ class QuerySetManager(object):
|
|||||||
opts = {'capped': True, 'size': max_size}
|
opts = {'capped': True, 'size': max_size}
|
||||||
if max_documents:
|
if max_documents:
|
||||||
opts['max'] = max_documents
|
opts['max'] = max_documents
|
||||||
self._collection = db.create_collection(collection, opts)
|
self._collection = db.create_collection(collection, **opts)
|
||||||
else:
|
else:
|
||||||
self._collection = db[collection]
|
self._collection = db[collection]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user