{"action":"created","issue":{"url":"https://api.github.com/repos/go-mgo/mgo/issues/92","labels_url":"https://api.github.com/repos/go-mgo/mgo/issues/92/labels{/name}","comments_url":"https://api.github.com/repos/go-mgo/mgo/issues/92/comments","events_url":"https://api.github.com/repos/go-mgo/mgo/issues/92/events","html_url":"https://github.com/go-mgo/mgo/issues/92","id":68322968,"number":92,"title":"Explicit ObjectId on Insert","user":{"login":"emirpasic","id":3115942,"avatar_url":"https://avatars.githubusercontent.com/u/3115942?v=3","gravatar_id":"","url":"https://api.github.com/users/emirpasic","html_url":"https://github.com/emirpasic","followers_url":"https://api.github.com/users/emirpasic/followers","following_url":"https://api.github.com/users/emirpasic/following{/other_user}","gists_url":"https://api.github.com/users/emirpasic/gists{/gist_id}","starred_url":"https://api.github.com/users/emirpasic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emirpasic/subscriptions","organizations_url":"https://api.github.com/users/emirpasic/orgs","repos_url":"https://api.github.com/users/emirpasic/repos","events_url":"https://api.github.com/users/emirpasic/events{/privacy}","received_events_url":"https://api.github.com/users/emirpasic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-14T09:54:48Z","updated_at":"2015-07-07T18:10:09Z","closed_at":"2015-05-11T17:29:18Z","body":"When running:\r\n\r\n```go\r\ninput := bson.M{\"_id\":bson.NewObjectId(), \"name\":\"emir\", \"job\":\"developer\"}\r\nerr = collection.Insert(input)\r\n```\r\n\r\nResult in Mongo DB is not ObjectId(\"hexhexhex\"), but some strangely escaped string:\r\n\r\n```\r\n{ \"_id\" : \"U,���)p\\u0006 \\u0000\\u0000\\u0001\", \"name\" : \"emir\", \"job\" : \"developer\" }\r\n```\r\n\r\nI would expect `_id` to be `ObjectId(\"552ce194ce29701430000002\")`\r\n\r\nEnvironment yielding results above:\r\n- mongo db v3.0.2 on centos\r\n- mongo db v3.0.1 on windows \r\n- mgo v2 (stable)\r\n- go v1.4.1"},"comment":{"url":"https://api.github.com/repos/go-mgo/mgo/issues/comments/119288675","html_url":"https://github.com/go-mgo/mgo/issues/92#issuecomment-119288675","issue_url":"https://api.github.com/repos/go-mgo/mgo/issues/92","id":119288675,"user":{"login":"emirpasic","id":3115942,"avatar_url":"https://avatars.githubusercontent.com/u/3115942?v=3","gravatar_id":"","url":"https://api.github.com/users/emirpasic","html_url":"https://github.com/emirpasic","followers_url":"https://api.github.com/users/emirpasic/followers","following_url":"https://api.github.com/users/emirpasic/following{/other_user}","gists_url":"https://api.github.com/users/emirpasic/gists{/gist_id}","starred_url":"https://api.github.com/users/emirpasic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emirpasic/subscriptions","organizations_url":"https://api.github.com/users/emirpasic/orgs","repos_url":"https://api.github.com/users/emirpasic/repos","events_url":"https://api.github.com/users/emirpasic/events{/privacy}","received_events_url":"https://api.github.com/users/emirpasic/received_events","type":"User","site_admin":false},"created_at":"2015-07-07T18:10:09Z","updated_at":"2015-07-07T18:10:09Z","body":"@byrnedo Nope, I ignored the issue and worked around it by creating my own \"id\" for each document instead, thus did not use the possibly mangled \"_id\" (ObjectId).\r\n\r\nI don't quite agree that this is a presentation issue, i.e. hexadecimal vs binary string as the author suggests, since I don't get a consistently expected behaviour when:\r\n1. Insert document with \"_id\" equal to ObjectId(\"552ce194ce29701430000002\")\r\n2. Find document with \"_id\" equal to ObjectId(\"552ce194ce29701430000002\") \r\n(2.) just does not happen, can't find it and when I directly connect to mongo and search for that document, then I encounter this issue of { \"_id\" : \"U,���)p\\u0006 \\u0000\\u0000\\u0001\" whereas documents I insert directly through the mongo client show a more readable hexadecimal value."}}