Bring back _cls and _id fields just as they return in pymongo

This commit is contained in:
Eddie Linder
2018-12-20 00:39:32 +02:00
parent 2c6a744848
commit b04dc90cdf
2 changed files with 17 additions and 12 deletions

View File

@@ -1845,10 +1845,7 @@ class BaseQuerySet(object):
# 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.ONLY and '_id' not in fields.fields) or
(fields.value == QueryFieldList.EXCLUDE and '_id' in fields.fields)
):
if fields and '_id' in doc and fields.value == QueryFieldList.EXCLUDE and '_id' in fields.fields:
del doc['_id']
return doc