$set replaces different key

3 views
Skip to first unread message

splix

unread,
Jul 2, 2010, 6:24:04 AM7/2/10
to mongodb-user
I'm trying to add some values using $set function, but found some
behavior that i don't understand.

What i'm doing:
--------------
> db.contacts.insert({"profile-id" : "test", "actual": {"key1": "val1"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "profile-id" : "test",
"actual" : { "key1" : "val1" } }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.key2": "val2"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2" }, "profile-id" : "test" }
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.001": "val3"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3" }, "profile-id" : "test" }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.002": "val4"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3", "002" : "val4" }, "profile-
id" : "test" }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.0020000000000000000000": "val5"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3", "002" : "val4",
"0020000000000000000000" : "val5" }, "profile-id" : "test" }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.0030000000000000000000": "val6"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3", "002" : "val4",
"0030000000000000000000" : "val6" }, "profile-id" : "test" }
--------------

All working right, except last operation. As you see at last step key
"0020000000000000000000" was removed, and was replaced by
"0030000000000000000000".

Is it ok? What i'm doing wrong? Maybe it's a bug?

I'm using:
$ mongod --version
db version v1.4.4, pdfile version 4.5
Fri Jul 2 14:02:42 git version:
9dcac11bd72c7cb34ca278313f033efcdd4908eb

Kyle Banker

unread,
Jul 2, 2010, 9:07:49 AM7/2/10
to mongod...@googlegroups.com
Looks like it's probably an issue. Just created this JIRA. which you can track.



--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


splix

unread,
Jul 3, 2010, 12:59:48 PM7/3/10
to mongodb-user
i'd tested it on mongo 1.2.4 also:

$ mongod --version
db version v1.2.4, pdfile version 4.5
Sat Jul 3 20:56:01 git version:
5cf582d3d96b882c400c33e7670b811ccd47f477

all working fine. Looks like it's only a 1.4.* bug
Reply all
Reply to author
Forward
0 new messages