{"action":"opened","number":4284,"pull_request":{"url":"https://api.github.com/repos/mongodb/mongoid/pulls/4284","id":69874343,"html_url":"https://github.com/mongodb/mongoid/pull/4284","diff_url":"https://github.com/mongodb/mongoid/pull/4284.diff","patch_url":"https://github.com/mongodb/mongoid/pull/4284.patch","issue_url":"https://api.github.com/repos/mongodb/mongoid/issues/4284","number":4284,"state":"open","locked":false,"title":"Don't assign empty documents to HasAndBelongsToMany association","user":{"login":"ElMassimo","id":1158253,"avatar_url":"https://avatars.githubusercontent.com/u/1158253?v=3","gravatar_id":"","url":"https://api.github.com/users/ElMassimo","html_url":"https://github.com/ElMassimo","followers_url":"https://api.github.com/users/ElMassimo/followers","following_url":"https://api.github.com/users/ElMassimo/following{/other_user}","gists_url":"https://api.github.com/users/ElMassimo/gists{/gist_id}","starred_url":"https://api.github.com/users/ElMassimo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElMassimo/subscriptions","organizations_url":"https://api.github.com/users/ElMassimo/orgs","repos_url":"https://api.github.com/users/ElMassimo/repos","events_url":"https://api.github.com/users/ElMassimo/events{/privacy}","received_events_url":"https://api.github.com/users/ElMassimo/received_events","type":"User","site_admin":false},"body":"Because [`values_at`](http://ruby-doc.org/core-2.1.0/Hash.html#method-i-values_at) will return an `Array` of values corresponding to each key, and it's possible for a document to be removed from the database without updating the inverse document in a `has_and_belongs_to_many` association, using `includes` to eager load the association can assign `nil` in the list of documents.\r\n\r\nSince that is not the behaviour when accessing a `has_and_belongs_to_many` association without eager loading (only the existing documents are loaded, no `nil`s), we should be consistent and do the same when eager loading.","created_at":"2016-05-12T17:18:15Z","updated_at":"2016-05-12T17:18:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mongodb/mongoid/pulls/4284/commits","review_comments_url":"https://api.github.com/repos/mongodb/mongoid/pulls/4284/comments","review_comment_url":"https://api.github.com/repos/mongodb/mongoid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb/mongoid/issues/4284/comments","statuses_url":"https://api.github.com/repos/mongodb/mongoid/statuses/61e5bb7b59b26dde04424d87d7d821ab6037ff31","head":{"label":"ElMassimo:fix/hbtm-eager-loading","ref":"fix/hbtm-eager-loading","sha":"61e5bb7b59b26dde04424d87d7d821ab6037ff31","user":{"login":"ElMassimo","id":1158253,"avatar_url":"https://avatars.githubusercontent.com/u/1158253?v=3","gravatar_id":"","url":"https://api.github.com/users/ElMassimo","html_url":"https://github.com/ElMassimo","followers_url":"https://api.github.com/users/ElMassimo/followers","following_url":"https://api.github.com/users/ElMassimo/following{/other_user}","gists_url":"https://api.github.com/users/ElMassimo/gists{/gist_id}","starred_url":"https://api.github.com/users/ElMassimo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElMassimo/subscriptions","organizations_url":"https://api.github.com/users/ElMassimo/orgs","repos_url":"https://api.github.com/users/ElMassimo/repos","events_url":"https://api.github.com/users/ElMassimo/events{/privacy}","received_events_url":"https://api.github.com/users/ElMassimo/received_events","type":"User","site_admin":false},"repo":{"id":22964858,"name":"mongoid","full_name":"ElMassimo/mongoid","owner":{"login":"ElMassimo","id":1158253,"avatar_url":"https://avatars.githubusercontent.com/u/1158253?v=3","gravatar_id":"","url":"https://api.github.com/users/ElMassimo","html_url":"https://github.com/ElMassimo","followers_url":"https://api.github.com/users/ElMassimo/followers","following_url":"https://api.github.com/users/ElMassimo/following{/other_user}","gists_url":"https://api.github.com/users/ElMassimo/gists{/gist_id}","starred_url":"https://api.github.com/users/ElMassimo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElMassimo/subscriptions","organizations_url":"https://api.github.com/users/ElMassimo/orgs","repos_url":"https://api.github.com/users/ElMassimo/repos","events_url":"https://api.github.com/users/ElMassimo/events{/privacy}","received_events_url":"https://api.github.com/users/ElMassimo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ElMassimo/mongoid","description":"Ruby ODM framework for MongoDB","fork":true,"url":"https://api.github.com/repos/ElMassimo/mongoid","forks_url":"https://api.github.com/repos/ElMassimo/mongoid/forks","keys_url":"https://api.github.com/repos/ElMassimo/mongoid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ElMassimo/mongoid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ElMassimo/mongoid/teams","hooks_url":"https://api.github.com/repos/ElMassimo/mongoid/hooks","issue_events_url":"https://api.github.com/repos/ElMassimo/mongoid/issues/events{/number}","events_url":"https://api.github.com/repos/ElMassimo/mongoid/events","assignees_url":"https://api.github.com/repos/ElMassimo/mongoid/assignees{/user}","branches_url":"https://api.github.com/repos/ElMassimo/mongoid/branches{/branch}","tags_url":"https://api.github.com/repos/ElMassimo/mongoid/tags","blobs_url":"https://api.github.com/repos/ElMassimo/mongoid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ElMassimo/mongoid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ElMassimo/mongoid/git/refs{/sha}","trees_url":"https://api.github.com/repos/ElMassimo/mongoid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ElMassimo/mongoid/statuses/{sha}","languages_url":"https://api.github.com/repos/ElMassimo/mongoid/languages","stargazers_url":"https://api.github.com/repos/ElMassimo/mongoid/stargazers","contributors_url":"https://api.github.com/repos/ElMassimo/mongoid/contributors","subscribers_url":"https://api.github.com/repos/ElMassimo/mongoid/subscribers","subscription_url":"https://api.github.com/repos/ElMassimo/mongoid/subscription","commits_url":"https://api.github.com/repos/ElMassimo/mongoid/commits{/sha}","git_commits_url":"https://api.github.com/repos/ElMassimo/mongoid/git/commits{/sha}","comments_url":"https://api.github.com/repos/ElMassimo/mongoid/comments{/number}","issue_comment_url":"https://api.github.com/repos/ElMassimo/mongoid/issues/comments{/number}","contents_url":"https://api.github.com/repos/ElMassimo/mongoid/contents/{+path}","compare_url":"https://api.github.com/repos/ElMassimo/mongoid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ElMassimo/mongoid/merges","archive_url":"https://api.github.com/repos/ElMassimo/mongoid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ElMassimo/mongoid/downloads","issues_url":"https://api.github.com/repos/ElMassimo/mongoid/issues{/number}","pulls_url":"https://api.github.com/repos/ElMassimo/mongoid/pulls{/number}","milestones_url":"https://api.github.com/repos/ElMassimo/mongoid/milestones{/number}","notifications_url":"https://api.github.com/repos/ElMassimo/mongoid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ElMassimo/mongoid/labels{/name}","releases_url":"https://api.github.com/repos/ElMassimo/mongoid/releases{/id}","deployments_url":"https://api.github.com/repos/ElMassimo/mongoid/deployments","created_at":"2014-08-14T18:50:40Z","updated_at":"2016-05-12T17:11:54Z","pushed_at":"2016-05-12T17:14:31Z","git_url":"git://github.com/ElMassimo/mongoid.git","ssh_url":"git@github.com:ElMassimo/mongoid.git","clone_url":"https://github.com/ElMassimo/mongoid.git","svn_url":"https://github.com/ElMassimo/mongoid","homepage":"http://mongoid.org","size":14095,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mongodb:master","ref":"master","sha":"7c2ff52a0c5292b8e6bf3a9a29bbb19abae3dd5f","user":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":309009,"name":"mongoid","full_name":"mongodb/mongoid","owner":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb/mongoid","description":"Ruby ODM framework for MongoDB","fork":false,"url":"https://api.github.com/repos/mongodb/mongoid","forks_url":"https://api.github.com/repos/mongodb/mongoid/forks","keys_url":"https://api.github.com/repos/mongodb/mongoid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/mongoid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/mongoid/teams","hooks_url":"https://api.github.com/repos/mongodb/mongoid/hooks","issue_events_url":"https://api.github.com/repos/mongodb/mongoid/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/mongoid/events","assignees_url":"https://api.github.com/repos/mongodb/mongoid/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/mongoid/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/mongoid/tags","blobs_url":"https://api.github.com/repos/mongodb/mongoid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/mongoid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/mongoid/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/mongoid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/mongoid/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/mongoid/languages","stargazers_url":"https://api.github.com/repos/mongodb/mongoid/stargazers","contributors_url":"https://api.github.com/repos/mongodb/mongoid/contributors","subscribers_url":"https://api.github.com/repos/mongodb/mongoid/subscribers","subscription_url":"https://api.github.com/repos/mongodb/mongoid/subscription","commits_url":"https://api.github.com/repos/mongodb/mongoid/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/mongoid/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/mongoid/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/mongoid/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/mongoid/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/mongoid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/mongoid/merges","archive_url":"https://api.github.com/repos/mongodb/mongoid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/mongoid/downloads","issues_url":"https://api.github.com/repos/mongodb/mongoid/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/mongoid/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/mongoid/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/mongoid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/mongoid/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/mongoid/releases{/id}","deployments_url":"https://api.github.com/repos/mongodb/mongoid/deployments","created_at":"2009-09-16T16:24:56Z","updated_at":"2016-05-09T13:16:03Z","pushed_at":"2016-05-08T19:23:37Z","git_url":"git://github.com/mongodb/mongoid.git","ssh_url":"git@github.com:mongodb/mongoid.git","clone_url":"https://github.com/mongodb/mongoid.git","svn_url":"https://github.com/mongodb/mongoid","homepage":"http://mongoid.org","size":21141,"stargazers_count":3351,"watchers_count":3351,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1176,"mirror_url":null,"open_issues_count":280,"forks":1176,"open_issues":280,"watchers":3351,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb/mongoid/pulls/4284"},"html":{"href":"https://github.com/mongodb/mongoid/pull/4284"},"issue":{"href":"https://api.github.com/repos/mongodb/mongoid/issues/4284"},"comments":{"href":"https://api.github.com/repos/mongodb/mongoid/issues/4284/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb/mongoid/pulls/4284/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb/mongoid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb/mongoid/pulls/4284/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb/mongoid/statuses/61e5bb7b59b26dde04424d87d7d821ab6037ff31"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":1,"deletions":1,"changed_files":1}}