diff --git a/package.json b/package.json index c40368d8af9..6a63dc64ef7 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "kareem": "2.3.2", "mongodb": "3.6.3", "mongoose-legacy-pluralize": "1.0.2", - "mpath": "0.8.0", + "mpath": "0.8.1", "mquery": "3.2.2", "ms": "2.1.2", "regexp-clone": "1.0.0", diff --git a/test/document.test.js b/test/document.test.js index dd4767d48d9..7c84cf539b1 100644 --- a/test/document.test.js +++ b/test/document.test.js @@ -9805,4 +9805,13 @@ describe('document', function() { assert.equal(err.message, 'test err'); }); }); + + it('returns undefined rather than entire object when calling `get()` with empty string (gh-9681)', function() { + const TestSchema = new Schema({ name: String }); + const TestModel = db.model('Test', TestSchema); + + const testObject = new TestModel({ name: 't' }); + + assert.strictEqual(testObject.get(''), void 0); + }); });