Get rid of _get_as_pymongo wrapper altogether as we return raw output
This commit is contained in:
parent
7fd4f792ba
commit
363aefe399
@ -188,7 +188,7 @@ class BaseQuerySet(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if queryset._as_pymongo:
|
if queryset._as_pymongo:
|
||||||
return queryset._get_as_pymongo(queryset._cursor[key])
|
return queryset._cursor[key]
|
||||||
|
|
||||||
return queryset._document._from_son(
|
return queryset._document._from_son(
|
||||||
queryset._cursor[key],
|
queryset._cursor[key],
|
||||||
@ -690,7 +690,7 @@ class BaseQuerySet(object):
|
|||||||
self._document._from_son(doc, only_fields=self.only_fields))
|
self._document._from_son(doc, only_fields=self.only_fields))
|
||||||
elif self._as_pymongo:
|
elif self._as_pymongo:
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
doc_map[doc['_id']] = self._get_as_pymongo(doc)
|
doc_map[doc['_id']] = doc
|
||||||
else:
|
else:
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
doc_map[doc['_id']] = self._document._from_son(
|
doc_map[doc['_id']] = self._document._from_son(
|
||||||
@ -1486,7 +1486,7 @@ class BaseQuerySet(object):
|
|||||||
raw_doc = six.next(self._cursor)
|
raw_doc = six.next(self._cursor)
|
||||||
|
|
||||||
if self._as_pymongo:
|
if self._as_pymongo:
|
||||||
return self._get_as_pymongo(raw_doc)
|
return raw_doc
|
||||||
|
|
||||||
doc = self._document._from_son(
|
doc = self._document._from_son(
|
||||||
raw_doc, _auto_dereference=self._auto_dereference,
|
raw_doc, _auto_dereference=self._auto_dereference,
|
||||||
@ -1833,19 +1833,6 @@ class BaseQuerySet(object):
|
|||||||
|
|
||||||
return tuple(data)
|
return tuple(data)
|
||||||
|
|
||||||
def _get_as_pymongo(self, doc):
|
|
||||||
"""Clean up a PyMongo doc, removing fields that were only fetched
|
|
||||||
for the sake of MongoEngine's implementation, and return it.
|
|
||||||
"""
|
|
||||||
# If the _id was not included in a .only or was excluded in a .exclude,
|
|
||||||
# remove it from the doc (we always fetch it so that we can properly
|
|
||||||
# construct documents).
|
|
||||||
fields = self._loaded_fields
|
|
||||||
if fields and '_id' in doc and fields.value == QueryFieldList.EXCLUDE and '_id' in fields.fields:
|
|
||||||
del doc['_id']
|
|
||||||
|
|
||||||
return doc
|
|
||||||
|
|
||||||
def _sub_js_fields(self, code):
|
def _sub_js_fields(self, code):
|
||||||
"""When fields are specified with [~fieldname] syntax, where
|
"""When fields are specified with [~fieldname] syntax, where
|
||||||
*fieldname* is the Python name of a field, *fieldname* will be
|
*fieldname* is the Python name of a field, *fieldname* will be
|
||||||
|
Loading…
x
Reference in New Issue
Block a user