{"action":"closed","issue":{"url":"https://api.github.com/repos/tliron/mongodb-jvm/issues/2","repository_url":"https://api.github.com/repos/tliron/mongodb-jvm","labels_url":"https://api.github.com/repos/tliron/mongodb-jvm/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/tliron/mongodb-jvm/issues/2/comments","events_url":"https://api.github.com/repos/tliron/mongodb-jvm/issues/2/events","html_url":"https://github.com/tliron/mongodb-jvm/issues/2","id":164785856,"number":2,"title":"Bulk inserts trigger exception in mongo-db.js","user":{"login":"mmilitzer","id":16718288,"avatar_url":"https://avatars.githubusercontent.com/u/16718288?v=3","gravatar_id":"","url":"https://api.github.com/users/mmilitzer","html_url":"https://github.com/mmilitzer","followers_url":"https://api.github.com/users/mmilitzer/followers","following_url":"https://api.github.com/users/mmilitzer/following{/other_user}","gists_url":"https://api.github.com/users/mmilitzer/gists{/gist_id}","starred_url":"https://api.github.com/users/mmilitzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmilitzer/subscriptions","organizations_url":"https://api.github.com/users/mmilitzer/orgs","repos_url":"https://api.github.com/users/mmilitzer/repos","events_url":"https://api.github.com/users/mmilitzer/events{/privacy}","received_events_url":"https://api.github.com/users/mmilitzer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-11T08:37:20Z","updated_at":"2016-07-11T15:03:59Z","closed_at":"2016-07-11T15:03:59Z","body":"Hi,\r\n\r\nI've noticed issues when trying to do bulk inserts. Basically, multiple documents can be inserted at once with one call to insert if instead of a single document an array of documents is given as the parameter.\r\n\r\nHowever doing this causes an exception in the mongo-db.js wrapper. The culprit is line 1468:\r\n\r\nhttps://github.com/tliron/mongodb-jvm/blob/master/components/sincerity/libraries/scripturian/mongo-db.js#L1468\r\n\r\nI think the problem is that with bulk inserts and an array of documents, there simply is not one \"_id\" field in the returned bson object (as with single document inserts). Therefore the \"get\" is for an undefined field and triggers an exception. In result, the \"insert\" does not complete correctly and it looks to the caller as if it failed.\r\n\r\nI've now just wrapped a try/catch around l. 1468 to ignore the exception if the \"_id\" field does not exist but that's likely not the real fix. \r\n\r\nWe are using an older version of the mongodb-jvm driver and mongo-db.js than what you have currently in git and so it might be that the problem is specific to our version. But from browsing the latest code here, it looks like the issue will still be present also in the latest version..."}}
{"actor":{"display_login":"tliron"}}