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

Upgrade to mongodb driver 3.6 #9299

Merged
merged 4 commits into from Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/model.js
Expand Up @@ -1362,7 +1362,7 @@ Model.syncIndexes = function syncIndexes(options, callback) {
cb = this.$wrapCallback(cb);

this.createCollection(err => {
if (err) {
if (err != null && err.codeName !== 'NamespaceExists') {
return cb(err);
}
this.cleanIndexes((err, dropped) => {
Expand Down Expand Up @@ -4848,7 +4848,7 @@ Model.$wrapCallback = function(callback) {
if (err != null && err.name === 'MongoServerSelectionError') {
arguments[0] = serverSelectionError.assimilateError(err);
}
if (err != null && err.name === 'MongoNetworkError' && err.message.endsWith('timed out')) {
if (err != null && err.name === 'MongoNetworkTimeoutError' && err.message.endsWith('timed out')) {
_this.db.emit('timeout');
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"bson": "^1.1.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think they now use bson 4.0.4, maybe this needs to be updated too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, they still use 1.1.x for 3.6. It would be a breaking change if they used 4.x: https://github.com/mongodb/node-mongodb-native/blob/d84d14b2c61e639b4e773c6b32ac509e9da53420/package.json#L28

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh my bad 🤗
Thanks for the explanation

"kareem": "2.3.1",
"mongodb": "3.5.10",
"mongodb": "3.6.0",
"mongoose-legacy-pluralize": "1.0.2",
"mpath": "0.7.0",
"mquery": "3.2.2",
Expand Down
22 changes: 12 additions & 10 deletions test/model.indexes.test.js
Expand Up @@ -20,7 +20,7 @@ describe('model', function() {
before(function() {
db = start();

return db.createCollection('Test');
return db.createCollection('Test').catch(() => {});
});

after(function(done) {
Expand Down Expand Up @@ -458,16 +458,18 @@ describe('model', function() {
const schema = new Schema({ arr: [childSchema] });
const Model = db.model('Test', schema);

return Model.init().
then(() => Model.syncIndexes()).
then(() => Model.listIndexes()).
then(indexes => {
assert.equal(indexes.length, 2);
assert.ok(indexes[1].partialFilterExpression);
assert.deepEqual(indexes[1].partialFilterExpression, {
'arr.name': { $exists: true }
});
return co(function*() {
yield Model.init();

yield Model.syncIndexes();
const indexes = yield Model.listIndexes();

assert.equal(indexes.length, 2);
assert.ok(indexes[1].partialFilterExpression);
assert.deepEqual(indexes[1].partialFilterExpression, {
'arr.name': { $exists: true }
});
});
});

it('skips automatic indexing on childSchema if autoIndex: false (gh-9150)', function() {
Expand Down