[CDRIVER-1573] Replace bulk_operation_update_with_opts()/bulk_operation_remove_with_opts() with bulk_operation_update_many_with_opts()/bulk_operation_remove_many_with_opts() Created: 30/Sep/16  Updated: 19/Oct/16  Resolved: 12/Oct/16

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

Type: Improvement Priority: Major - P3
Reporter: J Rassi Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-1525 Flexible opts for bulk operations Closed
is depended on by CXX-1052 Port CRUD methods to use C driver 1.5... Closed

 Description   

bulk_operation_remove_with_opts() has the awkward behavior that it will send an invalid operation to the server if the "limit" option is not specified. Similarly, bulk_operation_update_with_opts() has the unintuitive behavior that it will perform a single-update unless the "multi" option is specified as true.

These API functions should be removed and replaced with new API functions bulk_operation_remove_many_with_opts() and bulk_operation_update_many_with_opts(). Like their bulk_operation_*_one_with_opts() counterparts, these API functions should set the "multi" and "limit" options appropriately on the generated requests.



 Comments   
Comment by Githook User [ 12/Oct/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1573 _many_with_opts must only allow multi=true/limit=0 or else error
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/6eb3667c42e295b72020103dbcb2c0a74d9a3799

Comment by Githook User [ 12/Oct/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1573 Rename bulk_operation_[update|remove]with_opts to bulk_operation[update|remove]_many_with_opts
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/68283097da1f7efb887345f84f5fd7312a766bf0

Comment by A. Jesse Jiryu Davis [ 30/Sep/16 ]

I think it's helpful for future users of the C Driver to have:

  • mongoc_bulk_operation_remove_many_with_opts (this is a change)
  • mongoc_bulk_operation_remove_one_with_opts
  • mongoc_bulk_operation_replace_one_with_opts
  • mongoc_bulk_operation_update_many_with_opts (this is a change)
  • mongoc_bulk_operation_update_one_with_opts

My justification here is very similar to my justification in the original ticket: let's be more like the standard drivers. Being closer to the specs is better than being farther from the specs. Also, if this confused Rassi, imagine how easily we'll confuse users who aren't experts?

It's not too late to change this at all! But it will be too late if we don't do it before we release 1.5.0. In C Driver 2.0 these will be the only bulk operation functions, so let's make them perfect now, and then we won't have to change them again later.

More changes:

  • mongoc_bulk_operation_remove_many_with_opts must prohibit a "limit" option
  • mongoc_bulk_operation_remove_one_with_opts must prohibit a "limit" except for 1, and add "limit: 1" if there's no limit
  • mongoc_bulk_operation_replace_one_with_opts must prohibit a "multi" option except for "false"
  • mongoc_bulk_operation_update_many_with_opts must prohibit a "multi" option except for "true", and add "multi: true" if there's no "multi"
  • mongoc_bulk_operation_update_one_with_opts must prohibit a "multi" option except for "false"
Comment by Hannes Magnusson [ 30/Sep/16 ]

You are right that mongoc_bulk_operation_remove_with_opts should set limit=0 if none was provided and mongoc_bulk_update_with_opts should set multi=true if none provided. That makes sense and consistent with the existing functions.

I don't agree with the renaming though. The _with_opts functions are modelled after the current functions where by they do "multi" by default, and then there is a _one variant of that function.
It maybe should be have _one and _many in the getgo, but I feel its to late the introduce those now – what do you think jesse?

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