|
As you have found it errors without the $all, which is really just a long version for equality, on 2.4 and 2.6 as it is designed to.
// 2.4
|
> db.Food.update( { "names" : "corn"}, { "$addToSet" : { "names" : "corn"}}, { upsert: true });
|
WriteResult({
|
...
|
"errmsg" : "Cannot apply $addToSet modifier to non-array"}})
|
|
// 2.6
|
> db.Food.update( { "names" : "corn"}, {"$addToSet" : {"names" : "corn"}}, {upsert: true });
|
WriteResult({
|
...
|
"errmsg" : "Cannot apply $addToSet to a non-array field. Field named 'names' has a non-array type String in the document INVALID-MUTABLE-ELEMENT" }})
|
The behavior you are seeing with 2.4 + $all is just a bug that has been remedied in 2.6 when we re-wrote both the query + update frameworks.
|