Skip to content

Commit 43f88db

Browse files
committedDec 10, 2020
fix(document): ensure calling get() with empty string returns undefined for mongoose-plugin-autoinc
Fix #9681
1 parent 369efe1 commit 43f88db

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"kareem": "2.3.2",
2525
"mongodb": "3.6.3",
2626
"mongoose-legacy-pluralize": "1.0.2",
27-
"mpath": "0.8.0",
27+
"mpath": "0.8.1",
2828
"mquery": "3.2.2",
2929
"ms": "2.1.2",
3030
"regexp-clone": "1.0.0",

‎test/document.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -9805,4 +9805,13 @@ describe('document', function() {
98059805
assert.equal(err.message, 'test err');
98069806
});
98079807
});
9808+
9809+
it('returns undefined rather than entire object when calling `get()` with empty string (gh-9681)', function() {
9810+
const TestSchema = new Schema({ name: String });
9811+
const TestModel = db.model('Test', TestSchema);
9812+
9813+
const testObject = new TestModel({ name: 't' });
9814+
9815+
assert.strictEqual(testObject.get(''), void 0);
9816+
});
98089817
});

0 commit comments

Comments
 (0)