{"action":"created","comment":{"url":"https://api.github.com/repos/elixir-lang/ecto/pulls/comments/66850541","id":66850541,"diff_hunk":"@@ -330,4 +271,72 @@ defmodule Ecto.MultiTest do\n       Multi.new |> Multi.run(:run, fun) |> Multi.run(:run, fun)\n     end\n   end\n+\n+  test \"merge with fun\" do\n+    changeset = Changeset.change(%Comment{})\n+    multi =\n+      Multi.new\n+      |> Multi.insert(:insert, changeset)\n+      |> Multi.merge(fn data ->\n+        Multi.new |> Multi.update(:update, Changeset.change(data.insert))\n+      end)\n+\n+    assert {:ok, data} = TestRepo.transaction(multi)\n+    assert %Comment{} = data.insert\n+    assert %Comment{} = data.update\n+  end\n+\n+  test \"merge with mfa\" do\n+    changeset = Changeset.change(%Comment{})\n+    multi =\n+      Multi.new\n+      |> Multi.insert(:insert, changeset)\n+      |> Multi.merge(__MODULE__, :multi, [])\n+\n+      assert {:ok, data} = TestRepo.transaction(multi)\n+      assert %Comment{} = data.insert\n+      assert %Comment{} = data.update\n+  end\n+\n+  test \"merge rollbacks on errors\" do\n+    error = fn _ -> {:error, :error} end\n+    ok    = fn _ -> {:ok, :ok} end\n+\n+    multi =\n+      Multi.new\n+      |> Multi.run(:outside_ok, ok)\n+      |> Multi.merge(fn _ ->","path":"test/ecto/multi_test.exs","position":166,"original_position":166,"commit_id":"ab9a4b41a6ed842057241f0621d35967361e96b8","original_commit_id":"459dae731b66cda044e6e3988f060db1f538f228","user":{"login":"michalmuskala","id":477062,"avatar_url":"https://avatars.githubusercontent.com/u/477062?v=3","gravatar_id":"","url":"https://api.github.com/users/michalmuskala","html_url":"https://github.com/michalmuskala","followers_url":"https://api.github.com/users/michalmuskala/followers","following_url":"https://api.github.com/users/michalmuskala/following{/other_user}","gists_url":"https://api.github.com/users/michalmuskala/gists{/gist_id}","starred_url":"https://api.github.com/users/michalmuskala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalmuskala/subscriptions","organizations_url":"https://api.github.com/users/michalmuskala/orgs","repos_url":"https://api.github.com/users/michalmuskala/repos","events_url":"https://api.github.com/users/michalmuskala/events{/privacy}","received_events_url":"https://api.github.com/users/michalmuskala/received_events","type":"User","site_admin":false},"body":"done","created_at":"2016-06-13T19:18:32Z","updated_at":"2016-06-13T19:18:32Z","html_url":"https://github.com/elixir-lang/ecto/pull/1482#discussion_r66850541","pull_request_url":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482","_links":{"self":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/comments/66850541"},"html":{"href":"https://github.com/elixir-lang/ecto/pull/1482#discussion_r66850541"},"pull_request":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482"}}},"pull_request":{"url":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482","id":73506321,"html_url":"https://github.com/elixir-lang/ecto/pull/1482","diff_url":"https://github.com/elixir-lang/ecto/pull/1482.diff","patch_url":"https://github.com/elixir-lang/ecto/pull/1482.patch","issue_url":"https://api.github.com/repos/elixir-lang/ecto/issues/1482","number":1482,"state":"open","locked":false,"title":"Add Ecto.Multi.merge/2","user":{"login":"michalmuskala","id":477062,"avatar_url":"https://avatars.githubusercontent.com/u/477062?v=3","gravatar_id":"","url":"https://api.github.com/users/michalmuskala","html_url":"https://github.com/michalmuskala","followers_url":"https://api.github.com/users/michalmuskala/followers","following_url":"https://api.github.com/users/michalmuskala/following{/other_user}","gists_url":"https://api.github.com/users/michalmuskala/gists{/gist_id}","starred_url":"https://api.github.com/users/michalmuskala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalmuskala/subscriptions","organizations_url":"https://api.github.com/users/michalmuskala/orgs","repos_url":"https://api.github.com/users/michalmuskala/repos","events_url":"https://api.github.com/users/michalmuskala/events{/privacy}","received_events_url":"https://api.github.com/users/michalmuskala/received_events","type":"User","site_admin":false},"body":"The function passed to merge accepts an initial multi - that allows us to easily guard against duplicated operations, that would cause issues later on when merging results.\r\n\r\nThis still needs docs.\r\n\r\nCloses #1464","created_at":"2016-06-12T20:33:25Z","updated_at":"2016-06-13T19:18:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"643d0fea4362c777e60df522addf885ddd54d43e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482/commits","review_comments_url":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482/comments","review_comment_url":"https://api.github.com/repos/elixir-lang/ecto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elixir-lang/ecto/issues/1482/comments","statuses_url":"https://api.github.com/repos/elixir-lang/ecto/statuses/ab9a4b41a6ed842057241f0621d35967361e96b8","head":{"label":"elixir-lang:mm/multi-merge","ref":"mm/multi-merge","sha":"ab9a4b41a6ed842057241f0621d35967361e96b8","user":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars.githubusercontent.com/u/1481354?v=3","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":10649374,"name":"ecto","full_name":"elixir-lang/ecto","owner":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars.githubusercontent.com/u/1481354?v=3","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elixir-lang/ecto","description":"A database wrapper and language integrated query for Elixir","fork":false,"url":"https://api.github.com/repos/elixir-lang/ecto","forks_url":"https://api.github.com/repos/elixir-lang/ecto/forks","keys_url":"https://api.github.com/repos/elixir-lang/ecto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elixir-lang/ecto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elixir-lang/ecto/teams","hooks_url":"https://api.github.com/repos/elixir-lang/ecto/hooks","issue_events_url":"https://api.github.com/repos/elixir-lang/ecto/issues/events{/number}","events_url":"https://api.github.com/repos/elixir-lang/ecto/events","assignees_url":"https://api.github.com/repos/elixir-lang/ecto/assignees{/user}","branches_url":"https://api.github.com/repos/elixir-lang/ecto/branches{/branch}","tags_url":"https://api.github.com/repos/elixir-lang/ecto/tags","blobs_url":"https://api.github.com/repos/elixir-lang/ecto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elixir-lang/ecto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elixir-lang/ecto/git/refs{/sha}","trees_url":"https://api.github.com/repos/elixir-lang/ecto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elixir-lang/ecto/statuses/{sha}","languages_url":"https://api.github.com/repos/elixir-lang/ecto/languages","stargazers_url":"https://api.github.com/repos/elixir-lang/ecto/stargazers","contributors_url":"https://api.github.com/repos/elixir-lang/ecto/contributors","subscribers_url":"https://api.github.com/repos/elixir-lang/ecto/subscribers","subscription_url":"https://api.github.com/repos/elixir-lang/ecto/subscription","commits_url":"https://api.github.com/repos/elixir-lang/ecto/commits{/sha}","git_commits_url":"https://api.github.com/repos/elixir-lang/ecto/git/commits{/sha}","comments_url":"https://api.github.com/repos/elixir-lang/ecto/comments{/number}","issue_comment_url":"https://api.github.com/repos/elixir-lang/ecto/issues/comments{/number}","contents_url":"https://api.github.com/repos/elixir-lang/ecto/contents/{+path}","compare_url":"https://api.github.com/repos/elixir-lang/ecto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elixir-lang/ecto/merges","archive_url":"https://api.github.com/repos/elixir-lang/ecto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elixir-lang/ecto/downloads","issues_url":"https://api.github.com/repos/elixir-lang/ecto/issues{/number}","pulls_url":"https://api.github.com/repos/elixir-lang/ecto/pulls{/number}","milestones_url":"https://api.github.com/repos/elixir-lang/ecto/milestones{/number}","notifications_url":"https://api.github.com/repos/elixir-lang/ecto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elixir-lang/ecto/labels{/name}","releases_url":"https://api.github.com/repos/elixir-lang/ecto/releases{/id}","deployments_url":"https://api.github.com/repos/elixir-lang/ecto/deployments","created_at":"2013-06-12T18:42:06Z","updated_at":"2016-06-13T13:24:25Z","pushed_at":"2016-06-13T19:17:46Z","git_url":"git://github.com/elixir-lang/ecto.git","ssh_url":"git@github.com:elixir-lang/ecto.git","clone_url":"https://github.com/elixir-lang/ecto.git","svn_url":"https://github.com/elixir-lang/ecto","homepage":"","size":8549,"stargazers_count":1827,"watchers_count":1827,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":419,"mirror_url":null,"open_issues_count":16,"forks":419,"open_issues":16,"watchers":1827,"default_branch":"master"}},"base":{"label":"elixir-lang:master","ref":"master","sha":"4515c22dc60fe7d727098ce91b9340fd34bea035","user":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars.githubusercontent.com/u/1481354?v=3","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":10649374,"name":"ecto","full_name":"elixir-lang/ecto","owner":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars.githubusercontent.com/u/1481354?v=3","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elixir-lang/ecto","description":"A database wrapper and language integrated query for Elixir","fork":false,"url":"https://api.github.com/repos/elixir-lang/ecto","forks_url":"https://api.github.com/repos/elixir-lang/ecto/forks","keys_url":"https://api.github.com/repos/elixir-lang/ecto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elixir-lang/ecto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elixir-lang/ecto/teams","hooks_url":"https://api.github.com/repos/elixir-lang/ecto/hooks","issue_events_url":"https://api.github.com/repos/elixir-lang/ecto/issues/events{/number}","events_url":"https://api.github.com/repos/elixir-lang/ecto/events","assignees_url":"https://api.github.com/repos/elixir-lang/ecto/assignees{/user}","branches_url":"https://api.github.com/repos/elixir-lang/ecto/branches{/branch}","tags_url":"https://api.github.com/repos/elixir-lang/ecto/tags","blobs_url":"https://api.github.com/repos/elixir-lang/ecto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elixir-lang/ecto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elixir-lang/ecto/git/refs{/sha}","trees_url":"https://api.github.com/repos/elixir-lang/ecto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elixir-lang/ecto/statuses/{sha}","languages_url":"https://api.github.com/repos/elixir-lang/ecto/languages","stargazers_url":"https://api.github.com/repos/elixir-lang/ecto/stargazers","contributors_url":"https://api.github.com/repos/elixir-lang/ecto/contributors","subscribers_url":"https://api.github.com/repos/elixir-lang/ecto/subscribers","subscription_url":"https://api.github.com/repos/elixir-lang/ecto/subscription","commits_url":"https://api.github.com/repos/elixir-lang/ecto/commits{/sha}","git_commits_url":"https://api.github.com/repos/elixir-lang/ecto/git/commits{/sha}","comments_url":"https://api.github.com/repos/elixir-lang/ecto/comments{/number}","issue_comment_url":"https://api.github.com/repos/elixir-lang/ecto/issues/comments{/number}","contents_url":"https://api.github.com/repos/elixir-lang/ecto/contents/{+path}","compare_url":"https://api.github.com/repos/elixir-lang/ecto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elixir-lang/ecto/merges","archive_url":"https://api.github.com/repos/elixir-lang/ecto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elixir-lang/ecto/downloads","issues_url":"https://api.github.com/repos/elixir-lang/ecto/issues{/number}","pulls_url":"https://api.github.com/repos/elixir-lang/ecto/pulls{/number}","milestones_url":"https://api.github.com/repos/elixir-lang/ecto/milestones{/number}","notifications_url":"https://api.github.com/repos/elixir-lang/ecto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elixir-lang/ecto/labels{/name}","releases_url":"https://api.github.com/repos/elixir-lang/ecto/releases{/id}","deployments_url":"https://api.github.com/repos/elixir-lang/ecto/deployments","created_at":"2013-06-12T18:42:06Z","updated_at":"2016-06-13T13:24:25Z","pushed_at":"2016-06-13T19:17:46Z","git_url":"git://github.com/elixir-lang/ecto.git","ssh_url":"git@github.com:elixir-lang/ecto.git","clone_url":"https://github.com/elixir-lang/ecto.git","svn_url":"https://github.com/elixir-lang/ecto","homepage":"","size":8549,"stargazers_count":1827,"watchers_count":1827,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":419,"mirror_url":null,"open_issues_count":16,"forks":419,"open_issues":16,"watchers":1827,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482"},"html":{"href":"https://github.com/elixir-lang/ecto/pull/1482"},"issue":{"href":"https://api.github.com/repos/elixir-lang/ecto/issues/1482"},"comments":{"href":"https://api.github.com/repos/elixir-lang/ecto/issues/1482/comments"},"review_comments":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482/comments"},"review_comment":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/1482/commits"},"statuses":{"href":"https://api.github.com/repos/elixir-lang/ecto/statuses/ab9a4b41a6ed842057241f0621d35967361e96b8"}}}}
{"actor":{"display_login":"michalmuskala"}}