[CXX-612] command helpers attach read preference incorrectly Created: 08/Jun/15  Updated: 09/Sep/16  Resolved: 09/Sep/16

Status: Closed
Project: C++ Driver
Component/s: Testing
Affects Version/s: legacy-1.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Adam Midvidy Assignee: David Golden
Resolution: Won't Fix Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

If the C++ driver wants to product a count or distinct command, with say, readPreference "secondary" - it will produce a command like this:

{distinct: <collection name>, key: <keyname>, query: {filter: "myvalue", $readPreference: "secondary"}

The correct form, according to the server selection spec, would be:

{$query: {distinct: <collection name>. key: <keyname>, query: {filter: "myvalue"}, $readPreference: "secondary} 

The server historically accepted the first due to relatively imprecise rules for parsing read preference. As all drivers now follow the server selection spec method for attaching RP, the C++ driver should do the same.

This affects the helpers for count, distinct, mapreduce, and group.



 Comments   
Comment by David Golden [ 09/Sep/16 ]

Given the nature of the change involved, we're not going to fix this in the legacy driver.

Comment by Adam Midvidy [ 08/Oct/15 ]

Given that fixing this would require either a pretty ugly hack or a breaking change to the legacy driver, I'm going to move this out of legacy-1.0.6 for now and back into planning. We can revisit this later if a user requests it.

Comment by Githook User [ 25/Jun/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: CXX-612 attach read preference properly in count/distinct commands
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/17078b80e4fb29c9131a7c7ac16ddde3805d40bd

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