Skip to content

Commit

Permalink
fix(document): ensure calling get() with empty string returns undef…
Browse files Browse the repository at this point in the history
…ined for mongoose-plugin-autoinc

Fix #9681
  • Loading branch information
vkarpov15 committed Dec 10, 2020
1 parent 369efe1 commit 43f88db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions test/document.test.js
Expand Up @@ -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);
});
});

0 comments on commit 43f88db

Please sign in to comment.