fix-#397: Allow specifying the '_cls' as a field for indexes

This commit is contained in:
DavidBord
2014-08-03 12:54:22 +03:00
parent 41cfe5d2ca
commit 9b30afeca9
9 changed files with 46 additions and 8 deletions

View File

@@ -1413,8 +1413,11 @@ class BaseQuerySet(object):
def _query(self):
if self._mongo_query is None:
self._mongo_query = self._query_obj.to_query(self._document)
if self._class_check:
self._mongo_query.update(self._initial_query)
if self._class_check and self._initial_query:
if "_cls" in self._mongo_query:
self._mongo_query = {"$and": [self._initial_query, self._mongo_query]}
else:
self._mongo_query.update(self._initial_query)
return self._mongo_query
@property