[SERVER-3218] when i update a object, if a key not in object it should insert a new key, but i fact my existsing key are replaced by key Created: 08/Jun/11  Updated: 12/Jul/16  Resolved: 26/Jun/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 1.9.1

Type: Bug Priority: Major - P3
Reporter: gsk Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongodb 1.8.2


Issue Links:
Duplicate
is duplicated by SERVER-7499 Invalid "have conflicting mods in upd... Closed
Operating System: Windows
Participants:

 Description   

>
> db.test.foo.remove()
> db.test.foo.insert({"a":

{"c00":1}

, 'c':2})
> db.test.foo.update(

{"c":2}

, {'$inc':{'a.c000':1}})

> db.test.foo.find(

{"c":2}

)
{ "_id" : ObjectId("4def5621c3ac2d33b5f4d812"), "a" :

{ "c000" : 2 }

, "c" : 2 }
>

why not {"a":

{'c000":1, 'c00':1}

, 'c':2}



 Comments   
Comment by auto [ 16/Dec/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-3370 SERVER-3218 backport lexNumCmp fixes to 1.8
Branch: v1.8
https://github.com/mongodb/mongo/commit/e82f9ddc53a4fe24a40f190b45dc25b7ed88ed96

Comment by auto [ 26/Jun/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: fix lexNumCmp for middle 0 SERVER-3218
Branch: master
https://github.com/mongodb/mongo/commit/800d32536ba0a47518e53d855cbfc30ee0db265c

Comment by Antoine Girbal [ 09/Jun/11 ]

bug is in goodies.h line 515.
Basically it's supposed to get rid of leading 0s, but it doesnt check they are actually leading..

inline int lexNumCmp( const char *s1, const char *s2 ) {
...
bool n1 = isNumber( *s1 );
bool n2 = isNumber( *s2 );

if ( n1 && n2 ) {
// get rid of leading 0s
while ( *s1 == '0' ) s1++;
while ( *s2 == '0' ) s2++;
...

So any inner 0 is skipped for comparison.

Generated at Thu Feb 08 03:02:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.