@@ -2124,19 +2124,9 @@ def options(self, session=None):
2124
2124
2125
2125
def _aggregate (self , aggregation_command , pipeline , cursor_class , session ,
2126
2126
explicit_session , ** kwargs ):
2127
- # Remove things that are not command options.
2128
- use_cursor = True
2129
- if "useCursor" in kwargs :
2130
- warnings .warn (
2131
- "The useCursor option is deprecated "
2132
- "and will be removed in PyMongo 4.0" ,
2133
- DeprecationWarning , stacklevel = 2 )
2134
- use_cursor = common .validate_boolean (
2135
- "useCursor" , kwargs .pop ("useCursor" , True ))
2136
-
2137
2127
cmd = aggregation_command (
2138
2128
self , cursor_class , pipeline , kwargs , explicit_session ,
2139
- user_fields = {'cursor' : {'firstBatch' : 1 }}, use_cursor = use_cursor )
2129
+ user_fields = {'cursor' : {'firstBatch' : 1 }})
2140
2130
return self .__database .client ._retryable_read (
2141
2131
cmd .get_cursor , cmd .get_read_preference (session ), session ,
2142
2132
retryable = not cmd ._performs_write )
@@ -2155,13 +2145,10 @@ def aggregate(self, pipeline, session=None, **kwargs):
2155
2145
- `maxTimeMS` (int): The maximum amount of time to allow the operation
2156
2146
to run in milliseconds.
2157
2147
- `batchSize` (int): The maximum number of documents to return per
2158
- batch. Ignored if the connected mongod or mongos does not support
2159
- returning aggregate results using a cursor, or `useCursor` is
2160
- ``False``.
2148
+ batch.
2161
2149
- `collation` (optional): An instance of
2162
2150
:class:`~pymongo.collation.Collation`. This option is only supported
2163
2151
on MongoDB 3.4 and above.
2164
- - `useCursor` (bool): Deprecated. Will be removed in PyMongo 4.0.
2165
2152
2166
2153
The :meth:`aggregate` method obeys the :attr:`read_preference` of this
2167
2154
:class:`Collection`, except when ``$out`` or ``$merge`` are used, in
@@ -2186,6 +2173,8 @@ def aggregate(self, pipeline, session=None, **kwargs):
2186
2173
A :class:`~pymongo.command_cursor.CommandCursor` over the result
2187
2174
set.
2188
2175
2176
+ .. versionchanged:: 4.0
2177
+ Removed the ``useCursor`` option.
2189
2178
.. versionchanged:: 3.9
2190
2179
Apply this collection's read concern to pipelines containing the
2191
2180
`$out` stage when connected to MongoDB >= 4.2.
0 commit comments