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

feat: Deprecate top-level write concern option keys #2624

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
wrap config writeConcernMax in writeConcern
  • Loading branch information
HanaPearlman committed Nov 30, 2020
commit 6cdceaeb0a0b25d2c66ac1766e8105cdd016e1d1
8 changes: 4 additions & 4 deletions test/functional/bulk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ describe('Bulk', function() {
batch.insert({ b: 1 });

// Execute the operations
batch.execute(self.configuration.writeConcernMax(), function(err, result) {
batch.execute(self.configuration.writeConcernMax().writeConcern, function(err, result) {
expect(err).to.exist;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

writeConcernMax was changed to return a writeConcern formatted the new way-- writeConcern: {w:1, ...}. Bulk execute takes an actual WriteConcern object as its first parameter (this was changed in master), so we have to un-wrap the writeConcernMax result here.

expect(result).to.not.exist;

Expand Down Expand Up @@ -812,7 +812,7 @@ describe('Bulk', function() {
batch.insert({ a: 1 });

// Execute the operations
batch.execute(configuration.writeConcernMax(), (err, result) => {
batch.execute(configuration.writeConcernMax().writeConcern, (err, result) => {
expect(err).to.exist;
expect(result).to.not.exist;

Expand Down Expand Up @@ -872,7 +872,7 @@ describe('Bulk', function() {
batch.insert({ b: 1 });

// Execute the operations
batch.execute(self.configuration.writeConcernMax(), function(err, result) {
batch.execute(self.configuration.writeConcernMax().writeConcern, function(err, result) {
expect(err).to.exist;
expect(result).to.not.exist;

Expand Down Expand Up @@ -928,7 +928,7 @@ describe('Bulk', function() {
.updateOne({ $set: { b: 2 } });

// Execute the operations
batch.execute(self.configuration.writeConcernMax(), function(err, result) {
batch.execute(self.configuration.writeConcernMax().writeConcern, function(err, result) {
// Check state of result
test.equal(1, result.nUpserted);
test.equal(0, result.nInserted);
Expand Down
10 changes: 8 additions & 2 deletions test/tools/runner/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ class NativeConfiguration {
Object.assign(dbOptions, { replicaSet: this.options.replicaSet, auto_reconnect: false });
}

// Flatten any options nested under `writeConcern` before we make the connection string
if (dbOptions.writeConcern) {
Object.assign(dbOptions, dbOptions.writeConcern);
delete dbOptions.writeConcern;
}

const urlOptions = {
protocol: 'mongodb',
slashes: true,
Expand Down Expand Up @@ -224,10 +230,10 @@ class NativeConfiguration {

writeConcernMax() {
if (this.topologyType !== TopologyType.Single) {
return { w: 'majority', wtimeout: 30000 };
return { writeConcern: { w: 'majority', wtimeout: 30000 } };
}

return { w: 1 };
return { writeConcern: { w: 1 } };
}

Copy link
Contributor Author

@HanaPearlman HanaPearlman Nov 19, 2020

Choose a reason for hiding this comment

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

Per @nbbeeken 's suggestion. The benefit of making this change should be about half as many warnings during testing.

// Accessors and methods Client-Side Encryption
Expand Down