Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-576

Count command fails with default WriteConcern set

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.2.0
    • Affects Version/s: None
    • Component/s: None

      Reproduced with client version 1.1.1 and mongodb server versionĀ 3.6.18

      If a default write concern is set up on client:

      let mut opts = ClientOptions::parse(&url).await?;
      let wc = WriteConcern::builder().w(Acknowledgment::Majority).journal(true).build();
      opts.write_concern = Some(wc);
      let client = Client::with_options(opts)?;
      

      And then that client is used to preform a command that doesn't support writeConcern:

      client.database(db).collection(coll)
        .count_documents(filter, None).await?
      

      Command will fail with an error:

      Command failed (InvalidOptions): Command does not support writeConcern
      

      I've tried to set some `CountOptions` instead of using None, but it did not help.

      Workaround is to do not use a global WriteConcern, and set it on each request when needed, but IMO global wc is there for a reason, and this is a bug. Not sure if this is related to the somewhat ancient version of mongodb server I've tested this on, but it is officially supported by the rust driver as far as I know.

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            loshmeebre@gmail.com Milos Vucenovic
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: