Skip to content

Commit

Permalink
test(document): repro #7973
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 12, 2019
1 parent 4c56aab commit 651426c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4756,9 +4756,7 @@ describe('document', function() {
});

schema.virtual('tests').get(function() {
return this.nested.map(function(v) {
return v;
});
return Object.keys(this.nested).map(key => this.nested[key]);
});

const M = db.model('gh5078', schema);
Expand Down Expand Up @@ -7822,4 +7820,25 @@ describe('document', function() {
assert.equal(doc.once.prop, 'test');
});
});

it('handles objectids and decimals with strict: false (gh-7973)', function() {
const testSchema = Schema({}, { strict: false });
const Test = db.model('gh7973', testSchema);

let doc = new Test({
testId: new mongoose.Types.ObjectId(),
testDecimal: new mongoose.Types.Decimal128('1.23')
});

assert.ok(doc.testId instanceof mongoose.Types.ObjectId);
assert.ok(doc.testDecimal instanceof mongoose.Types.Decimal128);

return co(function*() {
yield doc.save();

doc = yield Test.collection.findOne();
assert.ok(doc.testId instanceof mongoose.Types.ObjectId);
assert.ok(doc.testDecimal instanceof mongoose.Types.Decimal128);
});
});
});

0 comments on commit 651426c

Please sign in to comment.