-
Type: Improvement
-
Resolution: Incomplete
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.5.2
-
Component/s: Internal Client
-
Labels:None
If we have some BSONObj with similar structure and we append them using the same BSONObjBuilder, the resulting BSONObjectBuilder.obj() is malformed...
For example:
BSONObj o[5] =
;
BSONObjBuilder b;
for (unsigned int i=0; i<5; ++i) b.appendElements(o[i]);
Resulting object from builder have three different 'subobj' fields. And if you insert this obj in database these three fields become identical (and repeated).
It would be useful if BSONObjBuilder could merge objects overwriting similar fields, so the previous code will gives an object like this:
{
"subobj" :
,
"simple" : 3,
"other" : 4
}
and not like this one (current behaviour):
{
"subobj" :
,
"subobj" :
,
"subobj" :
,
"simple" : 3,
"other" : 4
}
if you insert this object in db, and then you retrieve it, you'll read:
{
"subobj" :
,
"subobj" :
,
"subobj" :
,
"simple" : 3,
"other" : 4
}