[SERVER-11556] insert command does not move _id field to the front of BSON obj Created: 04/Nov/13  Updated: 11/Jul/16  Resolved: 30/Dec/13

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

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

Issue Links:
Duplicate
duplicates SERVER-11656 js_small_oplog failing because master... Closed
Related
related to SERVER-11558 Update (save -- upsert:true w/_id) re... Closed
Operating System: ALL
Participants:

 Description   

> db.user.insert({ x: 1, _id: 2 })
> db.user.find()
{ "_id" : 2, "x" : 1 }
> db.user.drop()
true
> db.runCommand({ insert: 'user', documents: [{ x: 1, _id: 2 }]})
{ "ok" : 1, "n" : 1 }
> db.user.find()
{ "x" : 1, "_id" : 2 }

Not sure if moving _id field to the front is the desired behavior, but eval8.js fails if we switch to using write commands because of this.



 Comments   
Comment by Githook User [ 30/Dec/13 ]

Author:

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

Message: SERVER-11556: test for moving _id to the front of documents on insert
Branch: master
https://github.com/mongodb/mongo/commit/616db7ddb0df0b4b5f7d2e7e118caf1f3023ca51

Comment by Scott Hernandez (Inactive) [ 11/Nov/13 ]

I take it back and we should always have _id first.

Comment by Eric Milkie [ 11/Nov/13 ]

This can result in replicated data that does not match the primary.

Comment by Scott Hernandez (Inactive) [ 04/Nov/13 ]

This is not desired behavior and the test can be fixed by using the assert.docEq function, which is order independent.

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