[CDRIVER-1539] Consider additional "opts" validation Created: 12/Sep/16  Updated: 21/Oct/16  Resolved: 21/Oct/16

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

Type: Improvement Priority: Minor - P4
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-1522 Add mongoc_collection_find_with_opts Closed

 Description   

Now that mongoc_collection_find calls _mongoc_cursor_new_with_opts, users could cause weird behavior by calling mongoc_collection_find with a query like:

query = BCON_NEW ("$query", "{", "}", "$limit", BCON_INT64 (3));
mongoc_collection_find (collection, MONGOC_QUERY_NONE, 0, 2 /* limit */, 0, query, NULL, NULL);

The driver will translate the unrecognized $-modifier "$limit" into an "opt" without the dollar called "limit", then add another "limit" to the opts from the limit parameter to mongoc_collection_find. It will send a find command like:

{find: 'collection', filter: {}, limit: 3, limit: 2}

Test and warn for invalid $-modifiers that conflict with mongoc_collection_find parameters?



 Comments   
Comment by A. Jesse Jiryu Davis [ 21/Oct/16 ]

Extra complexity in the driver risks bugs that affect all users. Not worth it to save a theoretical few users who might make a mistake.

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