Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use getters to sync BulkWriteResult wrappers #2716

Merged
merged 2 commits into from
Jan 28, 2021

Conversation

nbbeeken
Copy link
Contributor

Adds getters so that mergeBatchResults changes are reflected in wrapper
classes.

NODE-3055

Came across this bug while working on unified tests, these properties are new in 4.0 so this doesn't need a backport.

Adds getters so that mergeBatchResults changes are reflected in wrapper
classes.

NODE-3055
@nbbeeken nbbeeken marked this pull request as ready for review January 26, 2021 16:02
Copy link
Contributor

@emadum emadum left a comment

Choose a reason for hiding this comment

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

LGTM mod the typo in the test name

@@ -2583,4 +2584,45 @@ describe('Insert', function () {
});
}
});

it('MongoBulkWriteError.insertedCount should respect BulkWriteResult.insertedCount should respect BulkWrite.nInserted', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('MongoBulkWriteError.insertedCount should respect BulkWriteResult.insertedCount should respect BulkWrite.nInserted', function () {
it('MongoBulkWriteError.insertedCount should respect BulkWrite.nInserted', function () {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll give this a better name but this was actually correct MongoBulkWriteError holds a BulkWriteResult which holds the BulkWrite so this test makes sure the values thread correctly through the two wrapping classes

@nbbeeken
Copy link
Contributor Author

nbbeeken commented Jan 27, 2021

I mentioned in stand-up being concerned about printing these classes out being changed, so to follow up

Here's what it looks like on this fix:

{
  name: 'MongoBulkWriteError',
  code: 11000,
  writeErrors: [ WriteError { err: [Object] } ],
  result: BulkWriteResult {
    result: {
      ok: 1,
      writeErrors: [Array],
      writeConcernErrors: [],
      insertedIds: [Array],
      nInserted: 2,
      nUpserted: 0,
      nMatched: 0,
      nModified: 0,
      nRemoved: 0,
      upserted: []
    }
  }
}

Version 3.6

{
  driver: true,
  code: 11000,
  writeErrors: [ WriteError { err: [Object] } ],
  result: BulkWriteResult {
    result: {
      ok: 1,
      writeErrors: [Array],
      writeConcernErrors: [],
      insertedIds: [Array],
      nInserted: 2,
      nUpserted: 0,
      nMatched: 0,
      nModified: 0,
      nRemoved: 0,
      upserted: []
    }
  }
}

Essentially the same and it contains the information you would most likely be looking for

Copy link
Member

@durran durran left a comment

Choose a reason for hiding this comment

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

LGTM

@nbbeeken nbbeeken merged commit c94b54a into 4.0 Jan 28, 2021
@nbbeeken nbbeeken deleted the NODE-3055/fixBulkResultGetters branch January 28, 2021 15:06
ljhaywar pushed a commit that referenced this pull request Nov 9, 2021
Adds getters so that mergeBatchResults changes 
are reflected in wrapper classes.

NODE-3055
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.

3 participants