Skip to content

Commit

Permalink
fixed; Update with $pull from Mixed array
Browse files Browse the repository at this point in the history
closes #735
  • Loading branch information
aheckmann committed Jun 26, 2012
1 parent c69932d commit 82172af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/query.js
Expand Up @@ -1192,6 +1192,9 @@ Query.prototype._getSchema = function _getSchema (path) {

// look for arrays
return (function search (parts, schema) {
// array of Mixed?
if (!schema) return;

var p = parts.length + 1
, foundschema
, trypath
Expand Down
15 changes: 15 additions & 0 deletions test/model.update.test.js
Expand Up @@ -658,4 +658,19 @@ describe('model: update:', function(){
});
})

it('handles $pull from Mixed arrays (gh-735)', function(done){
var db = start();
var schema = new Schema({ comments: [] });
var M = db.model('gh-735', schema, 'gh-735_'+random());
M.create({ comments: [{ name: 'node 0.8' }] }, function (err, doc) {
assert.ifError(err);
M.update({ _id: doc._id }, { $pull: { comments: { name: 'node 0.8' }}}, function (err, affected) {
assert.ifError(err);
assert.equal(1, affected);
db.close();
done();
});
});
});

});

0 comments on commit 82172af

Please sign in to comment.