Skip to content

Commit c868ee7

Browse files
committed
test(update): repro #5086
1 parent 81714c2 commit c868ee7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/model.update.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,6 +2559,30 @@ describe('model: update:', function() {
25592559
catch(done);
25602560
});
25612561

2562+
it('defaults with overwrite and no update validators (gh-5384)', function(done) {
2563+
var testSchema = new mongoose.Schema({
2564+
name: String,
2565+
something: { type: Number, default: 2 }
2566+
});
2567+
2568+
var TestModel = db.model('gh5384', testSchema);
2569+
var options = {
2570+
overwrite: true,
2571+
upsert: true,
2572+
setDefaultsOnInsert: true
2573+
};
2574+
2575+
var update = { name: 'test' };
2576+
TestModel.update({ name: 'a' }, update, options, function(error) {
2577+
assert.ifError(error);
2578+
TestModel.findOne({}, function(error, doc) {
2579+
assert.ifError(error);
2580+
assert.equal(doc.something, 2);
2581+
done();
2582+
});
2583+
});
2584+
});
2585+
25622586
it('update validators with nested required (gh-5269)', function(done) {
25632587
var childSchema = new mongoose.Schema({
25642588
d1: {

0 commit comments

Comments
 (0)