Merge branch 'master' of git://github.com/flosch/mongoengine
Added unit test for get_or_create, merged flosch's get with punteney's get. Conflicts: mongoengine/queryset.py
This commit is contained in:
@@ -6,7 +6,6 @@ import pymongo
|
||||
class ValidationError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class BaseField(object):
|
||||
"""A base class for fields in a MongoDB document. Instances of this class
|
||||
may be added to subclasses of `Document` to define a document's schema.
|
||||
@@ -76,7 +75,10 @@ class ObjectIdField(BaseField):
|
||||
|
||||
def to_mongo(self, value):
|
||||
if not isinstance(value, pymongo.objectid.ObjectId):
|
||||
return pymongo.objectid.ObjectId(str(value))
|
||||
try:
|
||||
return pymongo.objectid.ObjectId(str(value))
|
||||
except Exception, e:
|
||||
raise ValidationError(e.message)
|
||||
return value
|
||||
|
||||
def prepare_query_value(self, value):
|
||||
|
||||
Reference in New Issue
Block a user