{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/33417365","id":33417365,"diff_hunk":"@@ -366,10 +366,15 @@ def type_cast_calculated_value(value, type, operation = nil)\n       end\n     end\n \n-    # TODO: refactor to allow non-string `select_values` (eg. Arel nodes).\n     def select_for_count\n       if select_values.present?\n-        select_values.join(\", \")\n+        select_values.map do |field|","path":"activerecord/lib/active_record/relation/calculations.rb","position":8,"original_position":8,"commit_id":"c6c877b8ab33de18c37f2cfb879700a85399ff8c","original_commit_id":"c6c877b8ab33de18c37f2cfb879700a85399ff8c","user":{"login":"sgrif","id":1529387,"avatar_url":"https://avatars.githubusercontent.com/u/1529387?v=3","gravatar_id":"","url":"https://api.github.com/users/sgrif","html_url":"https://github.com/sgrif","followers_url":"https://api.github.com/users/sgrif/followers","following_url":"https://api.github.com/users/sgrif/following{/other_user}","gists_url":"https://api.github.com/users/sgrif/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrif/subscriptions","organizations_url":"https://api.github.com/users/sgrif/orgs","repos_url":"https://api.github.com/users/sgrif/repos","events_url":"https://api.github.com/users/sgrif/events{/privacy}","received_events_url":"https://api.github.com/users/sgrif/received_events","type":"User","site_admin":false},"body":"Do we even need to join strings here at all? If we just wrap the array in an `Arel::Nodes::Count`, the visitor should handle this for us.","created_at":"2015-06-27T23:16:22Z","updated_at":"2015-06-27T23:16:22Z","html_url":"https://github.com/rails/rails/pull/20653#discussion_r33417365","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/20653","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/33417365"},"html":{"href":"https://github.com/rails/rails/pull/20653#discussion_r33417365"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/20653"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/20653","id":38189524,"html_url":"https://github.com/rails/rails/pull/20653","diff_url":"https://github.com/rails/rails/pull/20653.diff","patch_url":"https://github.com/rails/rails/pull/20653.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/20653","number":20653,"state":"open","locked":false,"title":"Allow select using Arel and perform a count","user":{"login":"repinel","id":1685896,"avatar_url":"https://avatars.githubusercontent.com/u/1685896?v=3","gravatar_id":"","url":"https://api.github.com/users/repinel","html_url":"https://github.com/repinel","followers_url":"https://api.github.com/users/repinel/followers","following_url":"https://api.github.com/users/repinel/following{/other_user}","gists_url":"https://api.github.com/users/repinel/gists{/gist_id}","starred_url":"https://api.github.com/users/repinel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/repinel/subscriptions","organizations_url":"https://api.github.com/users/repinel/orgs","repos_url":"https://api.github.com/users/repinel/repos","events_url":"https://api.github.com/users/repinel/events{/privacy}","received_events_url":"https://api.github.com/users/repinel/received_events","type":"User","site_admin":false},"body":"It allows a query like `User.select(:name).count` to be written using Arel attribute as `User.select(User.arel_table[:name]).count`.","created_at":"2015-06-21T19:50:24Z","updated_at":"2015-06-27T23:16:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5196eb4b51ceb684a6103b35926ecc7945d89723","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/20653/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/20653/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/20653/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/c6c877b8ab33de18c37f2cfb879700a85399ff8c","head":{"label":"repinel:allow-arel-select-count","ref":"allow-arel-select-count","sha":"c6c877b8ab33de18c37f2cfb879700a85399ff8c","user":{"login":"repinel","id":1685896,"avatar_url":"https://avatars.githubusercontent.com/u/1685896?v=3","gravatar_id":"","url":"https://api.github.com/users/repinel","html_url":"https://github.com/repinel","followers_url":"https://api.github.com/users/repinel/followers","following_url":"https://api.github.com/users/repinel/following{/other_user}","gists_url":"https://api.github.com/users/repinel/gists{/gist_id}","starred_url":"https://api.github.com/users/repinel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/repinel/subscriptions","organizations_url":"https://api.github.com/users/repinel/orgs","repos_url":"https://api.github.com/users/repinel/repos","events_url":"https://api.github.com/users/repinel/events{/privacy}","received_events_url":"https://api.github.com/users/repinel/received_events","type":"User","site_admin":false},"repo":{"id":34342083,"name":"rails","full_name":"repinel/rails","owner":{"login":"repinel","id":1685896,"avatar_url":"https://avatars.githubusercontent.com/u/1685896?v=3","gravatar_id":"","url":"https://api.github.com/users/repinel","html_url":"https://github.com/repinel","followers_url":"https://api.github.com/users/repinel/followers","following_url":"https://api.github.com/users/repinel/following{/other_user}","gists_url":"https://api.github.com/users/repinel/gists{/gist_id}","starred_url":"https://api.github.com/users/repinel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/repinel/subscriptions","organizations_url":"https://api.github.com/users/repinel/orgs","repos_url":"https://api.github.com/users/repinel/repos","events_url":"https://api.github.com/users/repinel/events{/privacy}","received_events_url":"https://api.github.com/users/repinel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/repinel/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/repinel/rails","forks_url":"https://api.github.com/repos/repinel/rails/forks","keys_url":"https://api.github.com/repos/repinel/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/repinel/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/repinel/rails/teams","hooks_url":"https://api.github.com/repos/repinel/rails/hooks","issue_events_url":"https://api.github.com/repos/repinel/rails/issues/events{/number}","events_url":"https://api.github.com/repos/repinel/rails/events","assignees_url":"https://api.github.com/repos/repinel/rails/assignees{/user}","branches_url":"https://api.github.com/repos/repinel/rails/branches{/branch}","tags_url":"https://api.github.com/repos/repinel/rails/tags","blobs_url":"https://api.github.com/repos/repinel/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/repinel/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/repinel/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/repinel/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/repinel/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/repinel/rails/languages","stargazers_url":"https://api.github.com/repos/repinel/rails/stargazers","contributors_url":"https://api.github.com/repos/repinel/rails/contributors","subscribers_url":"https://api.github.com/repos/repinel/rails/subscribers","subscription_url":"https://api.github.com/repos/repinel/rails/subscription","commits_url":"https://api.github.com/repos/repinel/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/repinel/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/repinel/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/repinel/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/repinel/rails/contents/{+path}","compare_url":"https://api.github.com/repos/repinel/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/repinel/rails/merges","archive_url":"https://api.github.com/repos/repinel/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/repinel/rails/downloads","issues_url":"https://api.github.com/repos/repinel/rails/issues{/number}","pulls_url":"https://api.github.com/repos/repinel/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/repinel/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/repinel/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/repinel/rails/labels{/name}","releases_url":"https://api.github.com/repos/repinel/rails/releases{/id}","created_at":"2015-04-21T17:34:45Z","updated_at":"2015-04-27T15:33:23Z","pushed_at":"2015-06-23T11:20:47Z","git_url":"git://github.com/repinel/rails.git","ssh_url":"git@github.com:repinel/rails.git","clone_url":"https://github.com/repinel/rails.git","svn_url":"https://github.com/repinel/rails","homepage":"http://rubyonrails.org","size":143310,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"rails:master","ref":"master","sha":"f6797a7683e5367046217fa85900f0288a504f84","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-06-27T21:20:37Z","pushed_at":"2015-06-27T20:48:45Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":425594,"stargazers_count":26689,"watchers_count":26689,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10652,"mirror_url":null,"open_issues_count":811,"forks":10652,"open_issues":811,"watchers":26689,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/20653"},"html":{"href":"https://github.com/rails/rails/pull/20653"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/20653"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/20653/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/20653/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/20653/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/c6c877b8ab33de18c37f2cfb879700a85399ff8c"}}}}