[CXX-335] Ensure we handle Bulk API edge case (DRIVERS-151) Created: 10/Sep/14  Updated: 23/Oct/14  Resolved: 12/Sep/14

Status: Closed
Project: C++ Driver
Component/s: API, Implementation
Affects Version/s: None
Fix Version/s: legacy-1.0.0-rc1

Type: Task Priority: Blocker - P1
Reporter: Tyler Brock Assignee: Tyler Brock
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DRIVERS-151 Handle Bulk API edge case for pre-2.6... Closed

 Comments   
Comment by Tyler Brock [ 12/Sep/14 ]

We have this test in bulk_operation_test.cpp

    // DRIVERS-151
    TYPED_TEST(BulkOperationTest, ClientGeneratedUpsertId) {
        if (!this->testSupported()) return;
 
        BulkOperationBuilder bulk(this->c, TEST_NS, true);
        BSONObj cmdResult;
        this->c->runCommand("admin", BSON("buildinfo" << true), cmdResult);
 
        bulk.find(BSON("_id" << 0)).upsert().updateOne(BSON("$set" << BSON("a" << 0)));
        bulk.find(BSON("a" << 1)).upsert().replaceOne(BSON("_id" << 1));
 
        if (versionCmp(cmdResult["version"].toString(), "2.6.0") >= 0)
            bulk.find(BSON("_id" << 3)).upsert().replaceOne(BSON("_id" << 2));
        else
            bulk.find(BSON("_id" << 2)).upsert().replaceOne(BSON("_id" << 2));
 
        WriteResult result;
        bulk.execute(&WriteConcern::acknowledged, &result);
 
        ASSERT_EQUALS(result.nUpserted(), 3);
        ASSERT_EQUALS(result.upserted().size(), 3U);
 
        for (int i = 0; i < 3; ++i) {
            ASSERT_EQUALS(result.upserted()[i].getIntField("index"), i);
            ASSERT_EQUALS(result.upserted()[i].getIntField("_id"), i);
        }
    }

Comment by Tyler Brock [ 12/Sep/14 ]

This was done already in 817393ce

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