{"action":"created","comment":{"url":"https://api.github.com/repos/sequelize/sequelize/pulls/comments/39732006","id":39732006,"diff_hunk":"@@ -61,6 +61,44 @@ if (current.dialect.supports.groupedLimit) {\n         });\n       });\n \n+      it('should run a belongsToMany association in a separate query', function () {\n+        var User = this.sequelize.define('User', {})\n+          , Group = this.sequelize.define('Group', {})\n+          , sqlSpy = sinon.spy();\n+\n+        User.Groups = User.belongsToMany(Group, {as: 'groups', through: 'UserGroup'});\n+\n+        return this.sequelize.sync({force: true}).then(function () {\n+          return Promise.join(\n+            User.bulkCreate([1, 2].map(function(id) {\n+              return {id: id};\n+            })),\n+            Group.bulkCreate([1, 2].map(function(id) {\n+              return {id: id};\n+            }))\n+          ).then(_.spread(function (users, groups) {\n+            return Promise.join(\n+              users[0].addGroup(groups[0]),\n+              users[1].addGroups(groups)\n+            );\n+          })).then(function () {\n+            return User.findAll({\n+              include: [\n+                {association: User.Groups, separate: true}\n+              ],\n+              logging: sqlSpy\n+            });\n+          }).then(function (users) {\n+            expect(users[0].groups).to.be.ok;\n+            expect(users[0].groups.length).to.equal(1);\n+            expect(users[1].groups).to.be.ok;\n+            expect(users[1].groups.length).to.equal(2);\n+            expect(users[1].groups).to.include(users[0].groups[0]);\n+            expect(sqlSpy).to.have.been.calledThrice;\n+          });\n+        });\n+      });","path":"test/integration/include/seperate.test.js","position":40,"original_position":40,"commit_id":"d96b9cf1e2cb3162b7c260baa630571d2c5fa422","original_commit_id":"d96b9cf1e2cb3162b7c260baa630571d2c5fa422","user":{"login":"mickhansen","id":699049,"avatar_url":"https://avatars.githubusercontent.com/u/699049?v=3","gravatar_id":"","url":"https://api.github.com/users/mickhansen","html_url":"https://github.com/mickhansen","followers_url":"https://api.github.com/users/mickhansen/followers","following_url":"https://api.github.com/users/mickhansen/following{/other_user}","gists_url":"https://api.github.com/users/mickhansen/gists{/gist_id}","starred_url":"https://api.github.com/users/mickhansen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mickhansen/subscriptions","organizations_url":"https://api.github.com/users/mickhansen/orgs","repos_url":"https://api.github.com/users/mickhansen/repos","events_url":"https://api.github.com/users/mickhansen/events{/privacy}","received_events_url":"https://api.github.com/users/mickhansen/received_events","type":"User","site_admin":false},"body":"I do believe it forces `include.separate` on `include.limit`? It doesn't do it based on there being a general find limit though.\r\n\r\n@yotamofek It might be possible to reuse by adding an include to the HasMany.get call and then mapping that back, since yes, it effectively becomes a 1:M lookup when we already have the source (which we do).","created_at":"2015-09-17T10:44:02Z","updated_at":"2015-09-17T10:44:02Z","html_url":"https://github.com/sequelize/sequelize/pull/4525#discussion_r39732006","pull_request_url":"https://api.github.com/repos/sequelize/sequelize/pulls/4525","_links":{"self":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/comments/39732006"},"html":{"href":"https://github.com/sequelize/sequelize/pull/4525#discussion_r39732006"},"pull_request":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/4525"}}},"pull_request":{"url":"https://api.github.com/repos/sequelize/sequelize/pulls/4525","id":45221599,"html_url":"https://github.com/sequelize/sequelize/pull/4525","diff_url":"https://github.com/sequelize/sequelize/pull/4525.diff","patch_url":"https://github.com/sequelize/sequelize/pull/4525.patch","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/4525","number":4525,"state":"open","locked":false,"title":"implement #4376 - support for include:separate for belongsToMany","user":{"login":"yotamofek","id":1835307,"avatar_url":"https://avatars.githubusercontent.com/u/1835307?v=3","gravatar_id":"","url":"https://api.github.com/users/yotamofek","html_url":"https://github.com/yotamofek","followers_url":"https://api.github.com/users/yotamofek/followers","following_url":"https://api.github.com/users/yotamofek/following{/other_user}","gists_url":"https://api.github.com/users/yotamofek/gists{/gist_id}","starred_url":"https://api.github.com/users/yotamofek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yotamofek/subscriptions","organizations_url":"https://api.github.com/users/yotamofek/orgs","repos_url":"https://api.github.com/users/yotamofek/repos","events_url":"https://api.github.com/users/yotamofek/events{/privacy}","received_events_url":"https://api.github.com/users/yotamofek/received_events","type":"User","site_admin":false},"body":"Hey,\r\n\r\nImplements #4376 \r\n\r\nThis is my first attempt at contribution.\r\nPlease let me know if there are any bugs or anything missing.\r\n\r\nThanks,\r\nYotam.","created_at":"2015-09-16T20:42:33Z","updated_at":"2015-09-17T10:44:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a96ec80d1186ae9d75707d359d93bfb2dc8fb548","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sequelize/sequelize/pulls/4525/commits","review_comments_url":"https://api.github.com/repos/sequelize/sequelize/pulls/4525/comments","review_comment_url":"https://api.github.com/repos/sequelize/sequelize/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/4525/comments","statuses_url":"https://api.github.com/repos/sequelize/sequelize/statuses/d96b9cf1e2cb3162b7c260baa630571d2c5fa422","head":{"label":"yotamofek:belongs.to.many.separate","ref":"belongs.to.many.separate","sha":"d96b9cf1e2cb3162b7c260baa630571d2c5fa422","user":{"login":"yotamofek","id":1835307,"avatar_url":"https://avatars.githubusercontent.com/u/1835307?v=3","gravatar_id":"","url":"https://api.github.com/users/yotamofek","html_url":"https://github.com/yotamofek","followers_url":"https://api.github.com/users/yotamofek/followers","following_url":"https://api.github.com/users/yotamofek/following{/other_user}","gists_url":"https://api.github.com/users/yotamofek/gists{/gist_id}","starred_url":"https://api.github.com/users/yotamofek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yotamofek/subscriptions","organizations_url":"https://api.github.com/users/yotamofek/orgs","repos_url":"https://api.github.com/users/yotamofek/repos","events_url":"https://api.github.com/users/yotamofek/events{/privacy}","received_events_url":"https://api.github.com/users/yotamofek/received_events","type":"User","site_admin":false},"repo":{"id":42612192,"name":"sequelize","full_name":"yotamofek/sequelize","owner":{"login":"yotamofek","id":1835307,"avatar_url":"https://avatars.githubusercontent.com/u/1835307?v=3","gravatar_id":"","url":"https://api.github.com/users/yotamofek","html_url":"https://github.com/yotamofek","followers_url":"https://api.github.com/users/yotamofek/followers","following_url":"https://api.github.com/users/yotamofek/following{/other_user}","gists_url":"https://api.github.com/users/yotamofek/gists{/gist_id}","starred_url":"https://api.github.com/users/yotamofek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yotamofek/subscriptions","organizations_url":"https://api.github.com/users/yotamofek/orgs","repos_url":"https://api.github.com/users/yotamofek/repos","events_url":"https://api.github.com/users/yotamofek/events{/privacy}","received_events_url":"https://api.github.com/users/yotamofek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yotamofek/sequelize","description":"Sequelize is an easy-to-use multi sql dialect ORM for Node.js & io.js. It currently supports MySQL, MariaDB, SQLite, PostgreSQL and MSSQL.","fork":true,"url":"https://api.github.com/repos/yotamofek/sequelize","forks_url":"https://api.github.com/repos/yotamofek/sequelize/forks","keys_url":"https://api.github.com/repos/yotamofek/sequelize/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yotamofek/sequelize/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yotamofek/sequelize/teams","hooks_url":"https://api.github.com/repos/yotamofek/sequelize/hooks","issue_events_url":"https://api.github.com/repos/yotamofek/sequelize/issues/events{/number}","events_url":"https://api.github.com/repos/yotamofek/sequelize/events","assignees_url":"https://api.github.com/repos/yotamofek/sequelize/assignees{/user}","branches_url":"https://api.github.com/repos/yotamofek/sequelize/branches{/branch}","tags_url":"https://api.github.com/repos/yotamofek/sequelize/tags","blobs_url":"https://api.github.com/repos/yotamofek/sequelize/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yotamofek/sequelize/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yotamofek/sequelize/git/refs{/sha}","trees_url":"https://api.github.com/repos/yotamofek/sequelize/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yotamofek/sequelize/statuses/{sha}","languages_url":"https://api.github.com/repos/yotamofek/sequelize/languages","stargazers_url":"https://api.github.com/repos/yotamofek/sequelize/stargazers","contributors_url":"https://api.github.com/repos/yotamofek/sequelize/contributors","subscribers_url":"https://api.github.com/repos/yotamofek/sequelize/subscribers","subscription_url":"https://api.github.com/repos/yotamofek/sequelize/subscription","commits_url":"https://api.github.com/repos/yotamofek/sequelize/commits{/sha}","git_commits_url":"https://api.github.com/repos/yotamofek/sequelize/git/commits{/sha}","comments_url":"https://api.github.com/repos/yotamofek/sequelize/comments{/number}","issue_comment_url":"https://api.github.com/repos/yotamofek/sequelize/issues/comments{/number}","contents_url":"https://api.github.com/repos/yotamofek/sequelize/contents/{+path}","compare_url":"https://api.github.com/repos/yotamofek/sequelize/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yotamofek/sequelize/merges","archive_url":"https://api.github.com/repos/yotamofek/sequelize/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yotamofek/sequelize/downloads","issues_url":"https://api.github.com/repos/yotamofek/sequelize/issues{/number}","pulls_url":"https://api.github.com/repos/yotamofek/sequelize/pulls{/number}","milestones_url":"https://api.github.com/repos/yotamofek/sequelize/milestones{/number}","notifications_url":"https://api.github.com/repos/yotamofek/sequelize/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yotamofek/sequelize/labels{/name}","releases_url":"https://api.github.com/repos/yotamofek/sequelize/releases{/id}","created_at":"2015-09-16T20:40:59Z","updated_at":"2015-09-16T20:41:01Z","pushed_at":"2015-09-16T20:41:22Z","git_url":"git://github.com/yotamofek/sequelize.git","ssh_url":"git@github.com:yotamofek/sequelize.git","clone_url":"https://github.com/yotamofek/sequelize.git","svn_url":"https://github.com/yotamofek/sequelize","homepage":"http://sequelizejs.com","size":60139,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"sequelize:master","ref":"master","sha":"abb9bd9635da7f4e9010697a182bba267c004eed","user":{"login":"sequelize","id":3591786,"avatar_url":"https://avatars.githubusercontent.com/u/3591786?v=3","gravatar_id":"","url":"https://api.github.com/users/sequelize","html_url":"https://github.com/sequelize","followers_url":"https://api.github.com/users/sequelize/followers","following_url":"https://api.github.com/users/sequelize/following{/other_user}","gists_url":"https://api.github.com/users/sequelize/gists{/gist_id}","starred_url":"https://api.github.com/users/sequelize/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequelize/subscriptions","organizations_url":"https://api.github.com/users/sequelize/orgs","repos_url":"https://api.github.com/users/sequelize/repos","events_url":"https://api.github.com/users/sequelize/events{/privacy}","received_events_url":"https://api.github.com/users/sequelize/received_events","type":"Organization","site_admin":false},"repo":{"id":790359,"name":"sequelize","full_name":"sequelize/sequelize","owner":{"login":"sequelize","id":3591786,"avatar_url":"https://avatars.githubusercontent.com/u/3591786?v=3","gravatar_id":"","url":"https://api.github.com/users/sequelize","html_url":"https://github.com/sequelize","followers_url":"https://api.github.com/users/sequelize/followers","following_url":"https://api.github.com/users/sequelize/following{/other_user}","gists_url":"https://api.github.com/users/sequelize/gists{/gist_id}","starred_url":"https://api.github.com/users/sequelize/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequelize/subscriptions","organizations_url":"https://api.github.com/users/sequelize/orgs","repos_url":"https://api.github.com/users/sequelize/repos","events_url":"https://api.github.com/users/sequelize/events{/privacy}","received_events_url":"https://api.github.com/users/sequelize/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sequelize/sequelize","description":"Sequelize is an easy-to-use multi sql dialect ORM for Node.js & io.js. It currently supports MySQL, MariaDB, SQLite, PostgreSQL and MSSQL.","fork":false,"url":"https://api.github.com/repos/sequelize/sequelize","forks_url":"https://api.github.com/repos/sequelize/sequelize/forks","keys_url":"https://api.github.com/repos/sequelize/sequelize/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sequelize/sequelize/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sequelize/sequelize/teams","hooks_url":"https://api.github.com/repos/sequelize/sequelize/hooks","issue_events_url":"https://api.github.com/repos/sequelize/sequelize/issues/events{/number}","events_url":"https://api.github.com/repos/sequelize/sequelize/events","assignees_url":"https://api.github.com/repos/sequelize/sequelize/assignees{/user}","branches_url":"https://api.github.com/repos/sequelize/sequelize/branches{/branch}","tags_url":"https://api.github.com/repos/sequelize/sequelize/tags","blobs_url":"https://api.github.com/repos/sequelize/sequelize/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sequelize/sequelize/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sequelize/sequelize/git/refs{/sha}","trees_url":"https://api.github.com/repos/sequelize/sequelize/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sequelize/sequelize/statuses/{sha}","languages_url":"https://api.github.com/repos/sequelize/sequelize/languages","stargazers_url":"https://api.github.com/repos/sequelize/sequelize/stargazers","contributors_url":"https://api.github.com/repos/sequelize/sequelize/contributors","subscribers_url":"https://api.github.com/repos/sequelize/sequelize/subscribers","subscription_url":"https://api.github.com/repos/sequelize/sequelize/subscription","commits_url":"https://api.github.com/repos/sequelize/sequelize/commits{/sha}","git_commits_url":"https://api.github.com/repos/sequelize/sequelize/git/commits{/sha}","comments_url":"https://api.github.com/repos/sequelize/sequelize/comments{/number}","issue_comment_url":"https://api.github.com/repos/sequelize/sequelize/issues/comments{/number}","contents_url":"https://api.github.com/repos/sequelize/sequelize/contents/{+path}","compare_url":"https://api.github.com/repos/sequelize/sequelize/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sequelize/sequelize/merges","archive_url":"https://api.github.com/repos/sequelize/sequelize/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sequelize/sequelize/downloads","issues_url":"https://api.github.com/repos/sequelize/sequelize/issues{/number}","pulls_url":"https://api.github.com/repos/sequelize/sequelize/pulls{/number}","milestones_url":"https://api.github.com/repos/sequelize/sequelize/milestones{/number}","notifications_url":"https://api.github.com/repos/sequelize/sequelize/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sequelize/sequelize/labels{/name}","releases_url":"https://api.github.com/repos/sequelize/sequelize/releases{/id}","created_at":"2010-07-22T07:11:11Z","updated_at":"2015-09-17T03:41:10Z","pushed_at":"2015-09-17T09:25:56Z","git_url":"git://github.com/sequelize/sequelize.git","ssh_url":"git@github.com:sequelize/sequelize.git","clone_url":"https://github.com/sequelize/sequelize.git","svn_url":"https://github.com/sequelize/sequelize","homepage":"http://sequelizejs.com","size":60139,"stargazers_count":4530,"watchers_count":4530,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1029,"mirror_url":null,"open_issues_count":539,"forks":1029,"open_issues":539,"watchers":4530,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/4525"},"html":{"href":"https://github.com/sequelize/sequelize/pull/4525"},"issue":{"href":"https://api.github.com/repos/sequelize/sequelize/issues/4525"},"comments":{"href":"https://api.github.com/repos/sequelize/sequelize/issues/4525/comments"},"review_comments":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/4525/comments"},"review_comment":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sequelize/sequelize/pulls/4525/commits"},"statuses":{"href":"https://api.github.com/repos/sequelize/sequelize/statuses/d96b9cf1e2cb3162b7c260baa630571d2c5fa422"}}}}