[SERVER-8101] BSON Obj Behavior while storing data into Database Created: 19/Oct/12  Updated: 07/Apr/23  Resolved: 07/Jan/13

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

Type: Bug Priority: Blocker - P1
Reporter: Shripad Bhargave Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

RHEL 6


Issue Links:
Duplicate
duplicates SERVER-718 in JS shell, duplicated fields should... Closed
Operating System: Linux
Participants:

 Description   

WE have issue with Holding BSONObj behaviour while holding values for Duplicate keys.

When we create BSON Obj and append some keys with same name using C++ driver and prints it contains then it shows all four keys with different values.

when we insert this created BSONObj into mongodb using C++ driver and check contains for perticuler row then it show that all keys having same value i.e. value of first key.

while the expected behaviour was the inserted row shall contain keys with same name but different values.

Example :
void somefuct()

{ DBClientConnection c; c.connect("localhost"); BSONObjBuilder b; b.append("inserTimestamp",1); b.append("inserTimestamp",2); b.append("inserTimestamp",3); b.append("inserTimestamp",4); BSONObj p = b.obj(); cout<<"Data"<<(p.toString()).c_str()<<endl; string strTable = "someDbName"+tablename; c.insert(strTable, p); } below is output for on Consol for COUT: { inserTimestamp: 1, inserTimestamp: 2, inserTimestamp: 3, inserTimestamp: 4 }

then after insertion below query run from mongclient to display inserted contents of BSONObj
> db.drill11.find({},

{"inserTimestamp":1}

)

{ "_id" : ObjectId("5080e294899514c25a7139e5"), "inserTimestamp" : 1, "inserTimestamp" : 1, "inserTimestamp" : 1, "inserTimestamp" : 1 }

so table have 4 columns with same keyname and same value which was not expected.

Kindy let us know on this behavior.



 Comments   
Comment by Scott Hernandez (Inactive) [ 07/Jan/13 ]

This is duplicate of this shell printing issue: SERVER-718

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