@@ -2287,7 +2287,7 @@ def _aggregate(self, aggregation_command, pipeline, cursor_class, session,
2287
2287
self , cursor_class , pipeline , kwargs , explicit_session ,
2288
2288
user_fields = {'cursor' : {'firstBatch' : 1 }}, use_cursor = use_cursor )
2289
2289
return self .__database .client ._retryable_read (
2290
- cmd .get_cursor , self . _read_preference_for (session ), session ,
2290
+ cmd .get_cursor , cmd . get_read_preference (session ), session ,
2291
2291
retryable = not cmd ._performs_write )
2292
2292
2293
2293
def aggregate (self , pipeline , session = None , ** kwargs ):
@@ -2313,11 +2313,9 @@ def aggregate(self, pipeline, session=None, **kwargs):
2313
2313
- `useCursor` (bool): Deprecated. Will be removed in PyMongo 4.0.
2314
2314
2315
2315
The :meth:`aggregate` method obeys the :attr:`read_preference` of this
2316
- :class:`Collection`. Please note that using the ``$out`` and ``$merge``
2317
- pipeline stages requires a read preference of
2318
- :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY` (the default).
2319
- The server will raise an error if the ``$out`` or ``$merge`` pipeline
2320
- stages are used with any other read preference.
2316
+ :class:`Collection`, except when ``$out`` or ``$merge`` are used, in
2317
+ which case :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`
2318
+ is used.
2321
2319
2322
2320
.. note:: This method does not support the 'explain' option. Please
2323
2321
use :meth:`~pymongo.database.Database.command` instead. An
@@ -2337,11 +2335,12 @@ def aggregate(self, pipeline, session=None, **kwargs):
2337
2335
A :class:`~pymongo.command_cursor.CommandCursor` over the result
2338
2336
set.
2339
2337
2340
- .. versionchanged:: 3.9
2341
- Added support for the ``$merge`` pipeline stage.
2342
2338
.. versionchanged:: 3.9
2343
2339
Apply this collection's read concern to pipelines containing the
2344
2340
`$out` stage when connected to MongoDB >= 4.2.
2341
+ Added support for the ``$merge`` pipeline stage.
2342
+ Aggregations that write always use read preference
2343
+ :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`.
2345
2344
.. versionchanged:: 3.6
2346
2345
Added the `session` parameter. Added the `maxAwaitTimeMS` option.
2347
2346
Deprecated the `useCursor` option.
0 commit comments