Skip to content

Conversation

@ShaneHarvey
Copy link
Member

@ShaneHarvey ShaneHarvey commented Feb 15, 2019

The old behavior was:

> session.startTransaction()
> session.getDatabase("test").runCommand({
   insert: 'c', 
   documents: [{_id: 0}, {_id: 0}]
})
{
    "ok" : 0,
    "errmsg" : "duplicate key error",
    "code" : 11000,
    "codeName" : "DuplicateKey"
}

The behavior after https://jira.mongodb.org/browse/SERVER-38583 is:

{
    "ok" : 1,
    "n" : 1,
    "writeErrors" : [
        {
            "index" : 1,
            "code" : 11000,
            "errmsg" : "duplicate key error"
        }
    ]
}

This error reporting change is going to be backported to 4.0.

For now I simply removed the errorCodeName: DuplicateKey assertions to get the tests to pass regardless of how the error is reported. Alternatively we could change the definition of errorCodeName to also look at error codes in writeErrors but since writeErrors don't have codeName we would either need to (re)introduce errorCode: 11000 or use the existing errorContains: duplicate key error.

Copy link
Contributor

@jyemin jyemin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants