Skip to content

Commit

Permalink
test(query): repro #5744
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Oct 28, 2017
1 parent b9ab446 commit 3b4211e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion test/model.update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,7 @@ describe('model: update:', function() {

User.update({}, update, opts).exec(function(error) {
assert.ok(error);
assert.ok(error.errors['notifications']);
assert.ok(error.errors['notifications.message']);

update.$pull.notifications.message = 'test';
User.update({ _id: doc._id }, update, opts).exec(function(error) {
Expand All @@ -2726,6 +2726,36 @@ describe('model: update:', function() {
});
});

it('$pull with updateValidators and $in (gh-5744)', function(done) {
var exampleSchema = mongoose.Schema({
subdocuments: [{
name: String
}]
});
var ExampleModel = db.model('gh5744', exampleSchema);
var exampleDocument = {
subdocuments: [{ name: 'First' }, { name: 'Second' }]
};

ExampleModel.create(exampleDocument, function(error, doc) {
assert.ifError(error);
ExampleModel.updateOne({ _id: doc._id }, {
$pull: {
subdocuments: {
_id: { $in: [doc.subdocuments[0]._id] }
}
}
}, { runValidators: true }, function(error) {
assert.ifError(error);
ExampleModel.findOne({ _id: doc._id }, function(error, doc) {
assert.ifError(error);
assert.equal(doc.subdocuments.length, 1);
done();
});
});
});
});

it('update with Decimal type (gh-5361)', function(done) {
start.mongodVersion(function(err, version) {
if (err) {
Expand Down

0 comments on commit 3b4211e

Please sign in to comment.