diff --git a/pymongo/aggregation.py b/pymongo/aggregation.py index 84ecffe5f..62fe4bd05 100644 --- a/pymongo/aggregation.py +++ b/pymongo/aggregation.py @@ -174,6 +174,7 @@ class _AggregationCommand(object): max_await_time_ms=self._max_await_time_ms, session=session, explicit_session=self._explicit_session, + comment=self._options.get("comment"), ) cmd_cursor._maybe_pin_connection(sock_info) return cmd_cursor diff --git a/pymongo/command_cursor.py b/pymongo/command_cursor.py index 0809d34e6..0c7fd6740 100644 --- a/pymongo/command_cursor.py +++ b/pymongo/command_cursor.py @@ -158,8 +158,6 @@ class CommandCursor(Generic[_DocumentType]): def __send_message(self, operation): """Send a getmore message and handle the response.""" client = self.__collection.database.client - if self.__comment is not None: - operation["comment"] = self.__comment try: response = client._run_operation( operation, self._unpack_response, address=self.__address @@ -211,7 +209,6 @@ class CommandCursor(Generic[_DocumentType]): """ if len(self.__data) or self.__killed: return len(self.__data) - if self.__id: # Get More dbname, collname = self.__ns.split(".", 1) read_pref = self.__collection._read_preference_for(self.session)