Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1668

Driver reads array elements less than two incorrectly.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 3.3.1
    • None
    • API, Implementation
    • Linux Fedora 28 64-bit,
      Processor: Intel® Core™ i5-7300HQ CPU @ 2.50GHz × 4.
      C driver 1.11.0(debug) also this problem was replicated with version 1.13.0(debug) (manually installed)
    • Fully Compatible

    Description

      Hello, Dear developers!

      Driver reads array elements less than two incorrectly.

      1. I have this code (which selects array of TEST_CASES from collection):

      auto collectionName = CollectionCnst::VARIANT;
      auto collection = db.collection(collectionName);
      auto doc = bsoncxx::v_noabi::builder::basic::document{};
      doc = bsoncxx::v_noabi::builder::basic::document{};
      doc.append(kvp(ID, bsoncxx::oid(ourVariantId)));
      auto cursor = collection.find_one({doc});
      if (cursor->view().length() == 0) {
         // not found
         throw std::exception();
      }
      // select testCase's
      auto testCases = cursor->view()[FieldCnst::TEST_CASES].get_array();
      return testCases.value;

      2. I want to iterate through it (foreach loop):

      for (auto &testCase: testCases) {

        // do smth

      }

      3. If I have 1 element in collection, loop don't invokes no one time. If I have two elements, it invokes 1 time. If I have three or more array elements, it invokes exactly through all elements.

      Attachments

        Activity

          People

            jesse@mongodb.com A. Jesse Jiryu Davis
            Ksenia989 Torgaeva Kseniya [X]
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: