{"action":"opened","number":1002,"pull_request":{"url":"https://api.github.com/repos/balderdashy/waterline/pulls/1002","id":35099130,"html_url":"https://github.com/balderdashy/waterline/pull/1002","diff_url":"https://github.com/balderdashy/waterline/pull/1002.diff","patch_url":"https://github.com/balderdashy/waterline/pull/1002.patch","issue_url":"https://api.github.com/repos/balderdashy/waterline/issues/1002","number":1002,"state":"open","locked":false,"title":"Fix callback being called multiple times when updating model with associations","user":{"login":"chotiwat","id":767257,"avatar_url":"https://avatars.githubusercontent.com/u/767257?v=3","gravatar_id":"","url":"https://api.github.com/users/chotiwat","html_url":"https://github.com/chotiwat","followers_url":"https://api.github.com/users/chotiwat/followers","following_url":"https://api.github.com/users/chotiwat/following{/other_user}","gists_url":"https://api.github.com/users/chotiwat/gists{/gist_id}","starred_url":"https://api.github.com/users/chotiwat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chotiwat/subscriptions","organizations_url":"https://api.github.com/users/chotiwat/orgs","repos_url":"https://api.github.com/users/chotiwat/repos","events_url":"https://api.github.com/users/chotiwat/events{/privacy}","received_events_url":"https://api.github.com/users/chotiwat/received_events","type":"User","site_admin":false},"body":"In `createBelongsTo()` of `lib/waterline/query/dql/update.js`, `valuesObject.associations.models` could be modified inside the iterator of `async.each()` function. This could lead to the final callback, which should be called only once, being called multiple times.\r\n\r\nHere's an example of the effect of modifying an array being iterated by `async.each()`:\r\n```js\r\nvar async = require('async');\r\nvar array = [1, 2, 3, 4, 5];\r\nasync.each(array, function(item, next) {\r\n  process.nextTick(function() {\r\n    console.log(item);\r\n    var index = array.indexOf(item);\r\n    array.splice(index, 1);\r\n    next();\r\n  });\r\n}, function() { console.log('done'); });\r\n```\r\nwill output:\r\n```\r\n1\r\n2\r\n3\r\ndone\r\n4\r\ndone\r\n5\r\ndone\r\n```","created_at":"2015-05-11T05:39:51Z","updated_at":"2015-05-11T05:39:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/balderdashy/waterline/pulls/1002/commits","review_comments_url":"https://api.github.com/repos/balderdashy/waterline/pulls/1002/comments","review_comment_url":"https://api.github.com/repos/balderdashy/waterline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/balderdashy/waterline/issues/1002/comments","statuses_url":"https://api.github.com/repos/balderdashy/waterline/statuses/d48ec20f03357fc078092bc1a95263e80efad88f","head":{"label":"wavify:fix-update-assoc","ref":"fix-update-assoc","sha":"d48ec20f03357fc078092bc1a95263e80efad88f","user":{"login":"wavify","id":1333034,"avatar_url":"https://avatars.githubusercontent.com/u/1333034?v=3","gravatar_id":"","url":"https://api.github.com/users/wavify","html_url":"https://github.com/wavify","followers_url":"https://api.github.com/users/wavify/followers","following_url":"https://api.github.com/users/wavify/following{/other_user}","gists_url":"https://api.github.com/users/wavify/gists{/gist_id}","starred_url":"https://api.github.com/users/wavify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wavify/subscriptions","organizations_url":"https://api.github.com/users/wavify/orgs","repos_url":"https://api.github.com/users/wavify/repos","events_url":"https://api.github.com/users/wavify/events{/privacy}","received_events_url":"https://api.github.com/users/wavify/received_events","type":"Organization","site_admin":false},"repo":{"id":35376328,"name":"waterline","full_name":"wavify/waterline","owner":{"login":"wavify","id":1333034,"avatar_url":"https://avatars.githubusercontent.com/u/1333034?v=3","gravatar_id":"","url":"https://api.github.com/users/wavify","html_url":"https://github.com/wavify","followers_url":"https://api.github.com/users/wavify/followers","following_url":"https://api.github.com/users/wavify/following{/other_user}","gists_url":"https://api.github.com/users/wavify/gists{/gist_id}","starred_url":"https://api.github.com/users/wavify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wavify/subscriptions","organizations_url":"https://api.github.com/users/wavify/orgs","repos_url":"https://api.github.com/users/wavify/repos","events_url":"https://api.github.com/users/wavify/events{/privacy}","received_events_url":"https://api.github.com/users/wavify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wavify/waterline","description":"An adapter-based ORM for Node.js  with support for mysql, mongo, postgres, redis, and more","fork":true,"url":"https://api.github.com/repos/wavify/waterline","forks_url":"https://api.github.com/repos/wavify/waterline/forks","keys_url":"https://api.github.com/repos/wavify/waterline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wavify/waterline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wavify/waterline/teams","hooks_url":"https://api.github.com/repos/wavify/waterline/hooks","issue_events_url":"https://api.github.com/repos/wavify/waterline/issues/events{/number}","events_url":"https://api.github.com/repos/wavify/waterline/events","assignees_url":"https://api.github.com/repos/wavify/waterline/assignees{/user}","branches_url":"https://api.github.com/repos/wavify/waterline/branches{/branch}","tags_url":"https://api.github.com/repos/wavify/waterline/tags","blobs_url":"https://api.github.com/repos/wavify/waterline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wavify/waterline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wavify/waterline/git/refs{/sha}","trees_url":"https://api.github.com/repos/wavify/waterline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wavify/waterline/statuses/{sha}","languages_url":"https://api.github.com/repos/wavify/waterline/languages","stargazers_url":"https://api.github.com/repos/wavify/waterline/stargazers","contributors_url":"https://api.github.com/repos/wavify/waterline/contributors","subscribers_url":"https://api.github.com/repos/wavify/waterline/subscribers","subscription_url":"https://api.github.com/repos/wavify/waterline/subscription","commits_url":"https://api.github.com/repos/wavify/waterline/commits{/sha}","git_commits_url":"https://api.github.com/repos/wavify/waterline/git/commits{/sha}","comments_url":"https://api.github.com/repos/wavify/waterline/comments{/number}","issue_comment_url":"https://api.github.com/repos/wavify/waterline/issues/comments{/number}","contents_url":"https://api.github.com/repos/wavify/waterline/contents/{+path}","compare_url":"https://api.github.com/repos/wavify/waterline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wavify/waterline/merges","archive_url":"https://api.github.com/repos/wavify/waterline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wavify/waterline/downloads","issues_url":"https://api.github.com/repos/wavify/waterline/issues{/number}","pulls_url":"https://api.github.com/repos/wavify/waterline/pulls{/number}","milestones_url":"https://api.github.com/repos/wavify/waterline/milestones{/number}","notifications_url":"https://api.github.com/repos/wavify/waterline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wavify/waterline/labels{/name}","releases_url":"https://api.github.com/repos/wavify/waterline/releases{/id}","created_at":"2015-05-10T15:25:26Z","updated_at":"2015-05-10T15:25:27Z","pushed_at":"2015-05-11T04:49:36Z","git_url":"git://github.com/wavify/waterline.git","ssh_url":"git@github.com:wavify/waterline.git","clone_url":"https://github.com/wavify/waterline.git","svn_url":"https://github.com/wavify/waterline","homepage":"","size":6301,"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":"balderdashy:master","ref":"master","sha":"fe402789bd89d343c3f673c95e01415a65ce8176","user":{"login":"balderdashy","id":1445252,"avatar_url":"https://avatars.githubusercontent.com/u/1445252?v=3","gravatar_id":"","url":"https://api.github.com/users/balderdashy","html_url":"https://github.com/balderdashy","followers_url":"https://api.github.com/users/balderdashy/followers","following_url":"https://api.github.com/users/balderdashy/following{/other_user}","gists_url":"https://api.github.com/users/balderdashy/gists{/gist_id}","starred_url":"https://api.github.com/users/balderdashy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balderdashy/subscriptions","organizations_url":"https://api.github.com/users/balderdashy/orgs","repos_url":"https://api.github.com/users/balderdashy/repos","events_url":"https://api.github.com/users/balderdashy/events{/privacy}","received_events_url":"https://api.github.com/users/balderdashy/received_events","type":"Organization","site_admin":false},"repo":{"id":9996255,"name":"waterline","full_name":"balderdashy/waterline","owner":{"login":"balderdashy","id":1445252,"avatar_url":"https://avatars.githubusercontent.com/u/1445252?v=3","gravatar_id":"","url":"https://api.github.com/users/balderdashy","html_url":"https://github.com/balderdashy","followers_url":"https://api.github.com/users/balderdashy/followers","following_url":"https://api.github.com/users/balderdashy/following{/other_user}","gists_url":"https://api.github.com/users/balderdashy/gists{/gist_id}","starred_url":"https://api.github.com/users/balderdashy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balderdashy/subscriptions","organizations_url":"https://api.github.com/users/balderdashy/orgs","repos_url":"https://api.github.com/users/balderdashy/repos","events_url":"https://api.github.com/users/balderdashy/events{/privacy}","received_events_url":"https://api.github.com/users/balderdashy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/balderdashy/waterline","description":"An adapter-based ORM for Node.js  with support for mysql, mongo, postgres, redis, and more","fork":false,"url":"https://api.github.com/repos/balderdashy/waterline","forks_url":"https://api.github.com/repos/balderdashy/waterline/forks","keys_url":"https://api.github.com/repos/balderdashy/waterline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/balderdashy/waterline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/balderdashy/waterline/teams","hooks_url":"https://api.github.com/repos/balderdashy/waterline/hooks","issue_events_url":"https://api.github.com/repos/balderdashy/waterline/issues/events{/number}","events_url":"https://api.github.com/repos/balderdashy/waterline/events","assignees_url":"https://api.github.com/repos/balderdashy/waterline/assignees{/user}","branches_url":"https://api.github.com/repos/balderdashy/waterline/branches{/branch}","tags_url":"https://api.github.com/repos/balderdashy/waterline/tags","blobs_url":"https://api.github.com/repos/balderdashy/waterline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/balderdashy/waterline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/balderdashy/waterline/git/refs{/sha}","trees_url":"https://api.github.com/repos/balderdashy/waterline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/balderdashy/waterline/statuses/{sha}","languages_url":"https://api.github.com/repos/balderdashy/waterline/languages","stargazers_url":"https://api.github.com/repos/balderdashy/waterline/stargazers","contributors_url":"https://api.github.com/repos/balderdashy/waterline/contributors","subscribers_url":"https://api.github.com/repos/balderdashy/waterline/subscribers","subscription_url":"https://api.github.com/repos/balderdashy/waterline/subscription","commits_url":"https://api.github.com/repos/balderdashy/waterline/commits{/sha}","git_commits_url":"https://api.github.com/repos/balderdashy/waterline/git/commits{/sha}","comments_url":"https://api.github.com/repos/balderdashy/waterline/comments{/number}","issue_comment_url":"https://api.github.com/repos/balderdashy/waterline/issues/comments{/number}","contents_url":"https://api.github.com/repos/balderdashy/waterline/contents/{+path}","compare_url":"https://api.github.com/repos/balderdashy/waterline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/balderdashy/waterline/merges","archive_url":"https://api.github.com/repos/balderdashy/waterline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/balderdashy/waterline/downloads","issues_url":"https://api.github.com/repos/balderdashy/waterline/issues{/number}","pulls_url":"https://api.github.com/repos/balderdashy/waterline/pulls{/number}","milestones_url":"https://api.github.com/repos/balderdashy/waterline/milestones{/number}","notifications_url":"https://api.github.com/repos/balderdashy/waterline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/balderdashy/waterline/labels{/name}","releases_url":"https://api.github.com/repos/balderdashy/waterline/releases{/id}","created_at":"2013-05-11T07:11:57Z","updated_at":"2015-05-10T15:30:16Z","pushed_at":"2015-05-07T10:31:01Z","git_url":"git://github.com/balderdashy/waterline.git","ssh_url":"git@github.com:balderdashy/waterline.git","clone_url":"https://github.com/balderdashy/waterline.git","svn_url":"https://github.com/balderdashy/waterline","homepage":"","size":6301,"stargazers_count":1669,"watchers_count":1669,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":272,"mirror_url":null,"open_issues_count":131,"forks":272,"open_issues":131,"watchers":1669,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/balderdashy/waterline/pulls/1002"},"html":{"href":"https://github.com/balderdashy/waterline/pull/1002"},"issue":{"href":"https://api.github.com/repos/balderdashy/waterline/issues/1002"},"comments":{"href":"https://api.github.com/repos/balderdashy/waterline/issues/1002/comments"},"review_comments":{"href":"https://api.github.com/repos/balderdashy/waterline/pulls/1002/comments"},"review_comment":{"href":"https://api.github.com/repos/balderdashy/waterline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/balderdashy/waterline/pulls/1002/commits"},"statuses":{"href":"https://api.github.com/repos/balderdashy/waterline/statuses/d48ec20f03357fc078092bc1a95263e80efad88f"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":1,"deletions":1,"changed_files":1}}