[CDRIVER-2998] Refactor _has_out_key to only inspect last pipeline stage Created: 07/Mar/19  Updated: 28/Oct/23  Resolved: 20/Aug/19

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: 1.16.0

Type: Improvement Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Isabel Atkinson
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

_has_out_key() currently returns true if any pipeline stage is $out. Since $out can only be used in the last position (server will error otherwise), we can optimize this function to only inspect the final stage.

There should be no negative effects to this change. If $out is used in the middle of a pipeline, libmongoc would then decide not to inherit a write concern and the server would ultimately return an error for a malformed pipeline.



 Comments   
Comment by Githook User [ 20/Aug/19 ]

Author:

{'username': 'isabelatkinson', 'email': 'isabelatkinson@gmail.com', 'name': 'isabelatkinson'}

Message: CDRIVER-2998 Refactor _has_write_key to inspect last stage only
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/d1b0c631d340a45ba1a5d07dd4e3cfab8e5ecca4

Generated at Wed Feb 07 21:16:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.