Skip to content

Commit

Permalink
Merge pull request #9299 from Automattic/gh-9188
Browse files Browse the repository at this point in the history
Upgrade to mongodb driver 3.6
  • Loading branch information
vkarpov15 committed Aug 12, 2020
2 parents 7006532 + 2b075ee commit 3e10b06
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
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",
"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

0 comments on commit 3e10b06

Please sign in to comment.