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

result::insert_one/insert_many returns possibly-dangling references for inserted ids, no definition provided for result::insert_many::result()

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.3
    • Affects Version/s: None
    • Component/s: Implementation
    • Labels:
      None

      My code:

                  std::vector<bsoncxx::document::value> documents;
                  for(int i = 0; i < 100; i++) {
                      documents.push_back(
                              bsoncxx::builder::stream::document{} << "i" << i << finalize);
                  }
                  auto result  = collection.insert_many(documents);
                  if(result) {
                      auto ids = result.value().inserted_ids();
                      for (auto it = ids.begin(); it != ids.end(); ++it) {
                          //cout << it->second.get_oid().value.to_string() << endl;
                          auto second = it->second;
                          auto oId = second.get_oid();
                          auto idValue = oId.value;
                          string str = idValue.to_string();
                      }
                  }
      

      I get the "src/bson/bson-iter.c:395 bson_iter_type(): precondition failed: iter->raw" exception on the "auto oId = second.get_oid();" line.

            Assignee:
            rassi J Rassi
            Reporter:
            tvyxen Igor Nikolaychuk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: