Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1526

Rename "_with_write_concern" functions to "_with_opts"

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.0
    • Affects Version/s: 1.5.0
    • Component/s: libmongoc
    • None
    • Fully Compatible

      Rename "_with_write_concern" functions (introduced in CDRIVER-1322) to "_with_opts", accept a const bson_t opts instead a mongoc_write_concern_t:

      • mongoc_collection_aggregate_with_opts mongoc_collection_aggregate already has bson_t *options that be retrofitted
      • mongoc_collection_create_index_with_opts
      • mongoc_collection_drop_index_with_opts
      • mongoc_collection_drop_with_opts
      • mongoc_collection_rename_with_opts
      • mongoc_database_create_collection_with_opts mongoc_database_create_collection already has bson_t *options that can be retrofitted
      • mongoc_database_drop_with_opts

      For consistency with the rest of our API, the final parameters of each of these functions should be ordered like:

         const bson_t *opts
         bson_error_t *error
      

      Or:

         const bson_t *opts
         bson_t *reply
         bson_error_t *error
      

      Their internal helper _mongoc_client_command_with_write_concern should become:

      • _mongoc_client_command_with_opts

      This function accepts a const bson_t "opts" instead of a mongoc_write_concern_t. Users can easily pass us a mongoc_write_concern_t in "opts" using mongoc_write_concern_append. The same rules currently enforced by _mongoc_client_command_with_write_concern MUST be enforced by the new _mongoc_client_command_with_opts:

      • If "opts" has a "writeConcern" subdocument, append it to the command iff max wire version >= 5
      • If "opts" has a "writeConcern" subdocument, parse the reply for "writeConcernError" and return false if there is a write concern error

      Besides "writeConcern", I think other fields in "opts" are appended to the command without any validation.

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: