-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: Deprecate top-level write concern option keys #2624
Conversation
15cd47d
to
a5362ff
Compare
2ef376f
to
0818bd8
Compare
19bbd0c
to
0b2c24d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking mostly good!
As the for the test output sometime it turns into a WALL of deprecations 😆
I'd take a look at test/tools/runner/config.js:225
specifically the writeConcernMax
method and see if changing that to the correct format will clean most of it up.
lib/gridfs/grid_store.js
Outdated
* @param {(number|string)} [options.w] DEPRECATED: The write concern. Use writeConcern instead. | ||
* @param {number} [options.wtimeout] DEPRECATED: The write concern timeout. Use writeConcern instead. | ||
* @param {boolean} [options.j=false] DEPRECATED: Specify a journal write concern. Use writeConcern instead. | ||
* @param {boolean} [options.fsync=false] DEPRECATED: Specify a file sync write concern. Use writeConcern instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.mongodb.com/manual/reference/write-concern/index.html
Fsync isn't an option anymore, its equivalent to journal, maybe this is a good opportunity to write a message: "since version x use journal instead"
@@ -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; |
There was a problem hiding this comment.
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.
} | ||
|
||
return { w: 1 }; | ||
return { writeConcern: { w: 1 } }; | ||
} | ||
|
There was a problem hiding this comment.
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.
5595c02
to
6977ed7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
One minor issue, Db.prototype.dropDatabase
doesn't have writeConcern
documented as an option but I think it does support it. While I don't think it needs to hold up this PR, we should probably go through and audit the Collection
/Db
objects to make sure all commands that support writeConcern
have it listed in the jsdoc.
6977ed7
to
6cdceae
Compare
Hi everyone, it seems that the new format for writeConcern options is not used everywhere in the driver (I think at least in ./lib/utils.js#mergeOptionsAndWriteConcern). So even when we pass the new format, we still get the depreciation message over and over. |
This PR is mostly documentation changes to indicate that keys
w
,j
,wtimeout
andfsync
are deprecated.Code changes include:
WriteConcern.fromOptions
now warns when the options contain the top-level keys and not thewriteConcern
key.writeConcern
key, so that warnings are not logged later. Options passed directly to the client are also moved under thewriteConcern
key, but only afterWriteConcern.fromOptions
is called, ensuring at least one warning is logged.options.writeConcern
, if it exists, when getting the write concern.Tests now spit out a ton of warns because the vast majority of tests which pass write concern options to client/operations use the top level keys.