{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/22177","labels_url":"https://api.github.com/repos/rails/rails/issues/22177/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/22177/comments","events_url":"https://api.github.com/repos/rails/rails/issues/22177/events","html_url":"https://github.com/rails/rails/pull/22177","id":114990306,"number":22177,"title":"Do not merge already merged joins [22022 fix]","user":{"login":"kv109","id":399968,"avatar_url":"https://avatars.githubusercontent.com/u/399968?v=3","gravatar_id":"","url":"https://api.github.com/users/kv109","html_url":"https://github.com/kv109","followers_url":"https://api.github.com/users/kv109/followers","following_url":"https://api.github.com/users/kv109/following{/other_user}","gists_url":"https://api.github.com/users/kv109/gists{/gist_id}","starred_url":"https://api.github.com/users/kv109/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kv109/subscriptions","organizations_url":"https://api.github.com/users/kv109/orgs","repos_url":"https://api.github.com/users/kv109/repos","events_url":"https://api.github.com/users/kv109/events{/privacy}","received_events_url":"https://api.github.com/users/kv109/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"chancancode","id":55829,"avatar_url":"https://avatars.githubusercontent.com/u/55829?v=3","gravatar_id":"","url":"https://api.github.com/users/chancancode","html_url":"https://github.com/chancancode","followers_url":"https://api.github.com/users/chancancode/followers","following_url":"https://api.github.com/users/chancancode/following{/other_user}","gists_url":"https://api.github.com/users/chancancode/gists{/gist_id}","starred_url":"https://api.github.com/users/chancancode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chancancode/subscriptions","organizations_url":"https://api.github.com/users/chancancode/orgs","repos_url":"https://api.github.com/users/chancancode/repos","events_url":"https://api.github.com/users/chancancode/events{/privacy}","received_events_url":"https://api.github.com/users/chancancode/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-11-04T07:30:25Z","updated_at":"2015-11-04T07:30:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/22177","html_url":"https://github.com/rails/rails/pull/22177","diff_url":"https://github.com/rails/rails/pull/22177.diff","patch_url":"https://github.com/rails/rails/pull/22177.patch"},"body":"Hi!\r\nI would like to start contributing to Rails. I thought this [issue](https://github.com/rails/rails/issues/22022) could be a good start.\r\n\r\nI was looking at `ActiveRecord::Relation::Merger` code, especially [`#merge_joins`] (https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/merger.rb#L107-L129) method. I realised that if you merge the same relation more than once, sql is simply duplicated (see [test](https://github.com/rails/rails/commit/550bfb88e201af6403c88e264d1b44d33c23a7f6)).\r\nProbably there are few solutions to this problem. One of them would be not to merge relation if it's already merged. I've tried this approach. I would love to hear if a) it's a good approach at all, and b) if I identified problem correctly.\r\n\r\nPS. Please show mercy, it's my first time :)"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/153616374","html_url":"https://github.com/rails/rails/pull/22177#issuecomment-153616374","issue_url":"https://api.github.com/repos/rails/rails/issues/22177","id":153616374,"user":{"login":"rails-bot","id":7468109,"avatar_url":"https://avatars.githubusercontent.com/u/7468109?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-bot","html_url":"https://github.com/rails-bot","followers_url":"https://api.github.com/users/rails-bot/followers","following_url":"https://api.github.com/users/rails-bot/following{/other_user}","gists_url":"https://api.github.com/users/rails-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-bot/subscriptions","organizations_url":"https://api.github.com/users/rails-bot/orgs","repos_url":"https://api.github.com/users/rails-bot/repos","events_url":"https://api.github.com/users/rails-bot/events{/privacy}","received_events_url":"https://api.github.com/users/rails-bot/received_events","type":"User","site_admin":false},"created_at":"2015-11-04T07:30:36Z","updated_at":"2015-11-04T07:30:36Z","body":"Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @chancancode (or someone else) soon.\n\nIf any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.\n\nPlease see [the contribution instructions](http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html) for more information.\n"}}