From 67f8512ee13248284a7d08bd2a40468d8a5bf1c2 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sat, 14 Sep 2019 20:14:30 -0400 Subject: [PATCH] test: repro #8150 --- test/document.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/document.test.js b/test/document.test.js index 3a840be158a..184b160f8fc 100644 --- a/test/document.test.js +++ b/test/document.test.js @@ -7904,6 +7904,24 @@ describe('document', function() { }); }); + it('caster that converts to Number class works (gh-8150)', function() { + return co(function*() { + const mySchema = new Schema({ + id: { + type: Number, + set: value => new Number(value.valueOf()) + } + }); + + const MyModel = db.model('gh8150', mySchema); + + yield MyModel.create({ id: 12345 }); + + const doc = yield MyModel.findOne({ id: 12345 }); + assert.ok(doc); + }); + }); + it('handles objectids and decimals with strict: false (gh-7973)', function() { const testSchema = Schema({}, { strict: false }); const Test = db.model('gh7973', testSchema);