{"action":"closed","number":1403,"pull_request":{"url":"https://api.github.com/repos/elixir-lang/ecto/pulls/1403","id":68107641,"html_url":"https://github.com/elixir-lang/ecto/pull/1403","diff_url":"https://github.com/elixir-lang/ecto/pull/1403.diff","patch_url":"https://github.com/elixir-lang/ecto/pull/1403.patch","issue_url":"https://api.github.com/repos/elixir-lang/ecto/issues/1403","number":1403,"state":"closed","locked":false,"title":"Support required has_many in traverse_errors","user":{"login":"moklett","id":4657,"avatar_url":"https://avatars.githubusercontent.com/u/4657?v=3","gravatar_id":"","url":"https://api.github.com/users/moklett","html_url":"https://github.com/moklett","followers_url":"https://api.github.com/users/moklett/followers","following_url":"https://api.github.com/users/moklett/following{/other_user}","gists_url":"https://api.github.com/users/moklett/gists{/gist_id}","starred_url":"https://api.github.com/users/moklett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moklett/subscriptions","organizations_url":"https://api.github.com/users/moklett/orgs","repos_url":"https://api.github.com/users/moklett/repos","events_url":"https://api.github.com/users/moklett/events{/privacy}","received_events_url":"https://api.github.com/users/moklett/received_events","type":"User","site_admin":false},"body":"A required has_many association already reports a Changeset error when the value is empty:\r\n\r\n    iex> changeset = %Author{}\r\n    iex>   |> Changeset.cast(%{posts: []}, ~w())\r\n    iex>   |> Changeset.cast_assoc(:posts, required: true)\r\n    iex> changeset.errors\r\n    [posts: {\"can't be blank\", []}]\r\n\r\nHowever, calling `Changeset.traverse_errors` on this changeset currently results in a blank set of errors for `posts`:\r\n\r\n    iex> Ecto.Changeset.traverse_errors(changeset, &(&1))\r\n    %{posts: []}\r\n\r\nThis happened because the errors on the nested association -- of which there were none -- overwrote the error on the parent for the association name, i.e. it was the equivalent of the following:\r\n\r\n    iex> Map.put(%{posts: [{\"can't be blank\", []}]}, :posts, [])\r\n    %{posts: []}\r\n\r\nThe fix has been implemented by merging the nested errors only if there is no error on the parent for the association.  I believe this is safe because if there is an error on the association itself, we should not care about errors on the children.","created_at":"2016-04-27T19:07:55Z","updated_at":"2016-04-27T19:16:28Z","closed_at":"2016-04-27T19:16:28Z","merged_at":"2016-04-27T19:16:28Z","merge_commit_sha":"9e48d77e5ad97078e892d9212e85a266972bfe7a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elixir-lang/ecto/pulls/1403/commits","review_comments_url":"https://api.github.com/repos/elixir-lang/ecto/pulls/1403/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/1403/comments","statuses_url":"https://api.github.com/repos/elixir-lang/ecto/statuses/132fcfc7a6fac1fa1b3eb3865845afbeb0513b03","head":{"label":"moklett:cast_assoc_traverse_errors","ref":"cast_assoc_traverse_errors","sha":"132fcfc7a6fac1fa1b3eb3865845afbeb0513b03","user":{"login":"moklett","id":4657,"avatar_url":"https://avatars.githubusercontent.com/u/4657?v=3","gravatar_id":"","url":"https://api.github.com/users/moklett","html_url":"https://github.com/moklett","followers_url":"https://api.github.com/users/moklett/followers","following_url":"https://api.github.com/users/moklett/following{/other_user}","gists_url":"https://api.github.com/users/moklett/gists{/gist_id}","starred_url":"https://api.github.com/users/moklett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moklett/subscriptions","organizations_url":"https://api.github.com/users/moklett/orgs","repos_url":"https://api.github.com/users/moklett/repos","events_url":"https://api.github.com/users/moklett/events{/privacy}","received_events_url":"https://api.github.com/users/moklett/received_events","type":"User","site_admin":false},"repo":{"id":57235071,"name":"ecto","full_name":"moklett/ecto","owner":{"login":"moklett","id":4657,"avatar_url":"https://avatars.githubusercontent.com/u/4657?v=3","gravatar_id":"","url":"https://api.github.com/users/moklett","html_url":"https://github.com/moklett","followers_url":"https://api.github.com/users/moklett/followers","following_url":"https://api.github.com/users/moklett/following{/other_user}","gists_url":"https://api.github.com/users/moklett/gists{/gist_id}","starred_url":"https://api.github.com/users/moklett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moklett/subscriptions","organizations_url":"https://api.github.com/users/moklett/orgs","repos_url":"https://api.github.com/users/moklett/repos","events_url":"https://api.github.com/users/moklett/events{/privacy}","received_events_url":"https://api.github.com/users/moklett/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/moklett/ecto","description":"A database wrapper and language integrated query for Elixir","fork":true,"url":"https://api.github.com/repos/moklett/ecto","forks_url":"https://api.github.com/repos/moklett/ecto/forks","keys_url":"https://api.github.com/repos/moklett/ecto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moklett/ecto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moklett/ecto/teams","hooks_url":"https://api.github.com/repos/moklett/ecto/hooks","issue_events_url":"https://api.github.com/repos/moklett/ecto/issues/events{/number}","events_url":"https://api.github.com/repos/moklett/ecto/events","assignees_url":"https://api.github.com/repos/moklett/ecto/assignees{/user}","branches_url":"https://api.github.com/repos/moklett/ecto/branches{/branch}","tags_url":"https://api.github.com/repos/moklett/ecto/tags","blobs_url":"https://api.github.com/repos/moklett/ecto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moklett/ecto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moklett/ecto/git/refs{/sha}","trees_url":"https://api.github.com/repos/moklett/ecto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moklett/ecto/statuses/{sha}","languages_url":"https://api.github.com/repos/moklett/ecto/languages","stargazers_url":"https://api.github.com/repos/moklett/ecto/stargazers","contributors_url":"https://api.github.com/repos/moklett/ecto/contributors","subscribers_url":"https://api.github.com/repos/moklett/ecto/subscribers","subscription_url":"https://api.github.com/repos/moklett/ecto/subscription","commits_url":"https://api.github.com/repos/moklett/ecto/commits{/sha}","git_commits_url":"https://api.github.com/repos/moklett/ecto/git/commits{/sha}","comments_url":"https://api.github.com/repos/moklett/ecto/comments{/number}","issue_comment_url":"https://api.github.com/repos/moklett/ecto/issues/comments{/number}","contents_url":"https://api.github.com/repos/moklett/ecto/contents/{+path}","compare_url":"https://api.github.com/repos/moklett/ecto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moklett/ecto/merges","archive_url":"https://api.github.com/repos/moklett/ecto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moklett/ecto/downloads","issues_url":"https://api.github.com/repos/moklett/ecto/issues{/number}","pulls_url":"https://api.github.com/repos/moklett/ecto/pulls{/number}","milestones_url":"https://api.github.com/repos/moklett/ecto/milestones{/number}","notifications_url":"https://api.github.com/repos/moklett/ecto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moklett/ecto/labels{/name}","releases_url":"https://api.github.com/repos/moklett/ecto/releases{/id}","deployments_url":"https://api.github.com/repos/moklett/ecto/deployments","created_at":"2016-04-27T18:05:46Z","updated_at":"2016-04-27T18:05:47Z","pushed_at":"2016-04-27T19:04:28Z","git_url":"git://github.com/moklett/ecto.git","ssh_url":"git@github.com:moklett/ecto.git","clone_url":"https://github.com/moklett/ecto.git","svn_url":"https://github.com/moklett/ecto","homepage":"","size":7298,"stargazers_count":0,"watchers_count":0,"language":"Elixir","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":"elixir-lang:master","ref":"master","sha":"6344234ffcb45467e52c57cac5fadaf2ec190129","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-04-27T19:14:34Z","pushed_at":"2016-04-27T19:16:28Z","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":8249,"stargazers_count":1690,"watchers_count":1690,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":374,"mirror_url":null,"open_issues_count":12,"forks":374,"open_issues":12,"watchers":1690,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/1403"},"html":{"href":"https://github.com/elixir-lang/ecto/pull/1403"},"issue":{"href":"https://api.github.com/repos/elixir-lang/ecto/issues/1403"},"comments":{"href":"https://api.github.com/repos/elixir-lang/ecto/issues/1403/comments"},"review_comments":{"href":"https://api.github.com/repos/elixir-lang/ecto/pulls/1403/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/1403/commits"},"statuses":{"href":"https://api.github.com/repos/elixir-lang/ecto/statuses/132fcfc7a6fac1fa1b3eb3865845afbeb0513b03"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"josevalim","id":9582,"avatar_url":"https://avatars.githubusercontent.com/u/9582?v=3","gravatar_id":"","url":"https://api.github.com/users/josevalim","html_url":"https://github.com/josevalim","followers_url":"https://api.github.com/users/josevalim/followers","following_url":"https://api.github.com/users/josevalim/following{/other_user}","gists_url":"https://api.github.com/users/josevalim/gists{/gist_id}","starred_url":"https://api.github.com/users/josevalim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josevalim/subscriptions","organizations_url":"https://api.github.com/users/josevalim/orgs","repos_url":"https://api.github.com/users/josevalim/repos","events_url":"https://api.github.com/users/josevalim/events{/privacy}","received_events_url":"https://api.github.com/users/josevalim/received_events","type":"User","site_admin":false},"comments":1,"review_comments":1,"commits":1,"additions":66,"deletions":1,"changed_files":3}}