This commit is contained in:
blackbrrr 2010-01-23 15:39:26 -06:00
parent f1e51f9708
commit 7aa0031dec

View File

@ -112,7 +112,6 @@ class QuerySet(object):
self._accessed_collection = False self._accessed_collection = False
self._query = {} self._query = {}
self._where_clauses = [] self._where_clauses = []
self._field_subset = []
# If inheritance is allowed, only return instances and instances of # If inheritance is allowed, only return instances and instances of
# subclasses of the class being used # subclasses of the class being used
@ -211,12 +210,7 @@ class QuerySet(object):
@property @property
def _cursor(self): def _cursor(self):
if not self._cursor_obj: if not self._cursor_obj:
query_kwargs = {} self._cursor_obj = self._collection.find(self._query)
if self._field_subset:
# load only a subset of fields
query_kwargs['fields'] = self._field_subset
self._cursor_obj = self._collection.find(self._query, **query_kwargs)
# Apply where clauses to cursor # Apply where clauses to cursor
for js in self._where_clauses: for js in self._where_clauses:
self._cursor_obj.where(js) self._cursor_obj.where(js)
@ -371,14 +365,6 @@ class QuerySet(object):
elif isinstance(key, int): elif isinstance(key, int):
return self._document._from_son(self._cursor[key]) return self._document._from_son(self._cursor[key])
def only(self, *fields):
"""Allow only a subset of fields to be loaded. Invalid fields
are silently ignored.
"""
fields = list(fields)
self._field_subset = fields
return self
def order_by(self, *keys): def order_by(self, *keys):
"""Order the :class:`~mongoengine.queryset.QuerySet` by the keys. The """Order the :class:`~mongoengine.queryset.QuerySet` by the keys. The
order may be specified by prepending each of the keys by a + or a -. order may be specified by prepending each of the keys by a + or a -.