-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.4.2
-
Component/s: None
-
None
-
Environment:Ubuntu 9.10 (on VMWare 6.5.1 under Windows 7)
Please, consider the following use case:
> use foo
switched to db foo
> db.test.insert({ Article : "Bla-bla", TagDesc : [
,
{Name: "Culture", Rate : 2 }] })
> db.runCommand({ findandmodify : "test", query :
, update : { $set :
{ "TagDesc.$.Name" : "Economics" } } })
{
"value" : {
"_id" : ObjectId("4bda64d1967d194e851b03ed"),
"Article" : "Bla-bla",
"TagDesc" : [
,
{ "Name" : "Culture", "Rate" : 2 } ]
},
"ok" : 1
}
server console output:
Fri Apr 30 08:07:36 foo.$cmd Caught Assertion in update , continuing
Fri Apr 30 08:07:36 update foo.test query:
exception userassert:can't append to array using string field name 0ms
The object was not changed
> db.test.find()
{ "_id" : ObjectId("4bda64d1967d194e851b03ed"), "Article" : "Bla-bla", "TagDesc" : [
,
{ "Name" : "Culture", "Rate" : 2 }] }
>
Note that at this time we specified index of item manually instead of using positional operator ( "TagDesc.$.Name" -> "TagDesc.1.Name" ).
And changes were applied successfully.
> db.runCommand({ findandmodify : "test", query :
, update : { $set :
{ "TagDesc.1.Name" : "Economics" } } })
{
"value" : {
"_id" : ObjectId("4bda64d1967d194e851b03ed"),
"Article" : "Bla-bla",
"TagDesc" : [
,
{ "Name" : "Culture", "Rate" : 2 } ]
},
"ok" : 1
}
> db.test.find()
{ "Article" : "Bla-bla", "TagDesc" : [
,
{ "Name" : "Economics", "Rate" : 2 }], "_id" : ObjectId("4bda64d1967d194e851b03ed") }
>