{"action":"created","comment":{"url":"https://api.github.com/repos/amatsuda/kaminari/pulls/comments/88164089","pull_request_review_id":8745554,"id":88164089,"diff_hunk":"@@ -65,6 +65,29 @@\n             @author.readers.by_read_count.page(1).total_count(:name, :distinct => true)\n           }.should_not raise_exception\n         end\n+\n+        it \"should count the number of rows, not the number of keys, with an alias field\" do\n+          @books.each {|book| book.readers << @readers[0..1] }\n+\n+          readerships = Readership.select('user_id, count(user_id) as read_count, book_id').group('user_id, book_id')","path":"spec/models/active_record/active_record_relation_methods_spec.rb","position":8,"original_position":8,"commit_id":"8a526a226bb361bcf8dbc9e1f3bc972e289bd245","original_commit_id":"8a526a226bb361bcf8dbc9e1f3bc972e289bd245","user":{"login":"yuki24","id":386234,"avatar_url":"https://avatars.githubusercontent.com/u/386234?v=3","gravatar_id":"","url":"https://api.github.com/users/yuki24","html_url":"https://github.com/yuki24","followers_url":"https://api.github.com/users/yuki24/followers","following_url":"https://api.github.com/users/yuki24/following{/other_user}","gists_url":"https://api.github.com/users/yuki24/gists{/gist_id}","starred_url":"https://api.github.com/users/yuki24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuki24/subscriptions","organizations_url":"https://api.github.com/users/yuki24/orgs","repos_url":"https://api.github.com/users/yuki24/repos","events_url":"https://api.github.com/users/yuki24/events{/privacy}","received_events_url":"https://api.github.com/users/yuki24/received_events","type":"User","site_admin":false},"body":"If you change `.group('user_id, book_id')` to `.group(:user_id, :book_id)`, this test will pass without your change.","created_at":"2016-11-16T03:46:05Z","updated_at":"2016-11-16T03:50:29Z","html_url":"https://github.com/amatsuda/kaminari/pull/573#discussion_r88164089","pull_request_url":"https://api.github.com/repos/amatsuda/kaminari/pulls/573","_links":{"self":{"href":"https://api.github.com/repos/amatsuda/kaminari/pulls/comments/88164089"},"html":{"href":"https://github.com/amatsuda/kaminari/pull/573#discussion_r88164089"},"pull_request":{"href":"https://api.github.com/repos/amatsuda/kaminari/pulls/573"}}},"pull_request":{"url":"https://api.github.com/repos/amatsuda/kaminari/pulls/573","id":17577234,"html_url":"https://github.com/amatsuda/kaminari/pull/573","diff_url":"https://github.com/amatsuda/kaminari/pull/573.diff","patch_url":"https://github.com/amatsuda/kaminari/pull/573.patch","issue_url":"https://api.github.com/repos/amatsuda/kaminari/issues/573","number":573,"state":"open","locked":false,"title":"Issue #572: grouped count (with aliased columns) issues","user":{"login":"chemica","id":431545,"avatar_url":"https://avatars.githubusercontent.com/u/431545?v=3","gravatar_id":"","url":"https://api.github.com/users/chemica","html_url":"https://github.com/chemica","followers_url":"https://api.github.com/users/chemica/followers","following_url":"https://api.github.com/users/chemica/following{/other_user}","gists_url":"https://api.github.com/users/chemica/gists{/gist_id}","starred_url":"https://api.github.com/users/chemica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chemica/subscriptions","organizations_url":"https://api.github.com/users/chemica/orgs","repos_url":"https://api.github.com/users/chemica/repos","events_url":"https://api.github.com/users/chemica/events{/privacy}","received_events_url":"https://api.github.com/users/chemica/received_events","type":"User","site_admin":false},"body":"ActiveRecord behaves problematically when an attempt is made to 'count' grouped queries. A hash is returned which doesn't contain the length of the returned set of groups, and an exception is thrown if the group clause uses any column aliases.\n\nThis is outlined in issue #572\n\nThis fix adds specs to highlight the issues and patches the total count functionality used for ActiveRecord. The fix has been tested against Travis for all supported AR versions.\n\nUnfortunately, the desired fix (using Arel) isn't compatible with AR 3.0, so the code falls back to string interpolation in this case. I understand from reading other support tickets that the project collaborators are opposed to string interpolation. I'm happy to start a discussion on how to avoid it.\n","created_at":"2014-06-25T08:25:32Z","updated_at":"2016-11-16T03:50:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b306a3ed32077bfddc6307c32599fd1fd8c1fe90","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/amatsuda/kaminari/pulls/573/commits","review_comments_url":"https://api.github.com/repos/amatsuda/kaminari/pulls/573/comments","review_comment_url":"https://api.github.com/repos/amatsuda/kaminari/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amatsuda/kaminari/issues/573/comments","statuses_url":"https://api.github.com/repos/amatsuda/kaminari/statuses/8a526a226bb361bcf8dbc9e1f3bc972e289bd245","head":{"label":"chemica:572-grouped-count","ref":"572-grouped-count","sha":"8a526a226bb361bcf8dbc9e1f3bc972e289bd245","user":{"login":"chemica","id":431545,"avatar_url":"https://avatars.githubusercontent.com/u/431545?v=3","gravatar_id":"","url":"https://api.github.com/users/chemica","html_url":"https://github.com/chemica","followers_url":"https://api.github.com/users/chemica/followers","following_url":"https://api.github.com/users/chemica/following{/other_user}","gists_url":"https://api.github.com/users/chemica/gists{/gist_id}","starred_url":"https://api.github.com/users/chemica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chemica/subscriptions","organizations_url":"https://api.github.com/users/chemica/orgs","repos_url":"https://api.github.com/users/chemica/repos","events_url":"https://api.github.com/users/chemica/events{/privacy}","received_events_url":"https://api.github.com/users/chemica/received_events","type":"User","site_admin":false},"repo":{"id":21134470,"name":"kaminari","full_name":"chemica/kaminari","owner":{"login":"chemica","id":431545,"avatar_url":"https://avatars.githubusercontent.com/u/431545?v=3","gravatar_id":"","url":"https://api.github.com/users/chemica","html_url":"https://github.com/chemica","followers_url":"https://api.github.com/users/chemica/followers","following_url":"https://api.github.com/users/chemica/following{/other_user}","gists_url":"https://api.github.com/users/chemica/gists{/gist_id}","starred_url":"https://api.github.com/users/chemica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chemica/subscriptions","organizations_url":"https://api.github.com/users/chemica/orgs","repos_url":"https://api.github.com/users/chemica/repos","events_url":"https://api.github.com/users/chemica/events{/privacy}","received_events_url":"https://api.github.com/users/chemica/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chemica/kaminari","description":"A Scope & Engine based, clean, powerful, customizable and sophisticated paginator for Rails 3 and 4","fork":true,"url":"https://api.github.com/repos/chemica/kaminari","forks_url":"https://api.github.com/repos/chemica/kaminari/forks","keys_url":"https://api.github.com/repos/chemica/kaminari/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chemica/kaminari/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chemica/kaminari/teams","hooks_url":"https://api.github.com/repos/chemica/kaminari/hooks","issue_events_url":"https://api.github.com/repos/chemica/kaminari/issues/events{/number}","events_url":"https://api.github.com/repos/chemica/kaminari/events","assignees_url":"https://api.github.com/repos/chemica/kaminari/assignees{/user}","branches_url":"https://api.github.com/repos/chemica/kaminari/branches{/branch}","tags_url":"https://api.github.com/repos/chemica/kaminari/tags","blobs_url":"https://api.github.com/repos/chemica/kaminari/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chemica/kaminari/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chemica/kaminari/git/refs{/sha}","trees_url":"https://api.github.com/repos/chemica/kaminari/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chemica/kaminari/statuses/{sha}","languages_url":"https://api.github.com/repos/chemica/kaminari/languages","stargazers_url":"https://api.github.com/repos/chemica/kaminari/stargazers","contributors_url":"https://api.github.com/repos/chemica/kaminari/contributors","subscribers_url":"https://api.github.com/repos/chemica/kaminari/subscribers","subscription_url":"https://api.github.com/repos/chemica/kaminari/subscription","commits_url":"https://api.github.com/repos/chemica/kaminari/commits{/sha}","git_commits_url":"https://api.github.com/repos/chemica/kaminari/git/commits{/sha}","comments_url":"https://api.github.com/repos/chemica/kaminari/comments{/number}","issue_comment_url":"https://api.github.com/repos/chemica/kaminari/issues/comments{/number}","contents_url":"https://api.github.com/repos/chemica/kaminari/contents/{+path}","compare_url":"https://api.github.com/repos/chemica/kaminari/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chemica/kaminari/merges","archive_url":"https://api.github.com/repos/chemica/kaminari/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chemica/kaminari/downloads","issues_url":"https://api.github.com/repos/chemica/kaminari/issues{/number}","pulls_url":"https://api.github.com/repos/chemica/kaminari/pulls{/number}","milestones_url":"https://api.github.com/repos/chemica/kaminari/milestones{/number}","notifications_url":"https://api.github.com/repos/chemica/kaminari/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chemica/kaminari/labels{/name}","releases_url":"https://api.github.com/repos/chemica/kaminari/releases{/id}","deployments_url":"https://api.github.com/repos/chemica/kaminari/deployments","created_at":"2014-06-23T16:59:45Z","updated_at":"2014-07-30T16:30:22Z","pushed_at":"2014-07-30T17:28:15Z","git_url":"git://github.com/chemica/kaminari.git","ssh_url":"git@github.com:chemica/kaminari.git","clone_url":"https://github.com/chemica/kaminari.git","svn_url":"https://github.com/chemica/kaminari","homepage":"https://github.com/amatsuda/kaminari/wiki","size":1212,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"amatsuda:master","ref":"master","sha":"fdc18906e823828ec64b466056e572b362d03cfe","user":{"login":"amatsuda","id":11493,"avatar_url":"https://avatars.githubusercontent.com/u/11493?v=3","gravatar_id":"","url":"https://api.github.com/users/amatsuda","html_url":"https://github.com/amatsuda","followers_url":"https://api.github.com/users/amatsuda/followers","following_url":"https://api.github.com/users/amatsuda/following{/other_user}","gists_url":"https://api.github.com/users/amatsuda/gists{/gist_id}","starred_url":"https://api.github.com/users/amatsuda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amatsuda/subscriptions","organizations_url":"https://api.github.com/users/amatsuda/orgs","repos_url":"https://api.github.com/users/amatsuda/repos","events_url":"https://api.github.com/users/amatsuda/events{/privacy}","received_events_url":"https://api.github.com/users/amatsuda/received_events","type":"User","site_admin":false},"repo":{"id":1333863,"name":"kaminari","full_name":"amatsuda/kaminari","owner":{"login":"amatsuda","id":11493,"avatar_url":"https://avatars.githubusercontent.com/u/11493?v=3","gravatar_id":"","url":"https://api.github.com/users/amatsuda","html_url":"https://github.com/amatsuda","followers_url":"https://api.github.com/users/amatsuda/followers","following_url":"https://api.github.com/users/amatsuda/following{/other_user}","gists_url":"https://api.github.com/users/amatsuda/gists{/gist_id}","starred_url":"https://api.github.com/users/amatsuda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amatsuda/subscriptions","organizations_url":"https://api.github.com/users/amatsuda/orgs","repos_url":"https://api.github.com/users/amatsuda/repos","events_url":"https://api.github.com/users/amatsuda/events{/privacy}","received_events_url":"https://api.github.com/users/amatsuda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amatsuda/kaminari","description":"⚡ A Scope & Engine based, clean, powerful, customizable and sophisticated paginator for Ruby webapps","fork":false,"url":"https://api.github.com/repos/amatsuda/kaminari","forks_url":"https://api.github.com/repos/amatsuda/kaminari/forks","keys_url":"https://api.github.com/repos/amatsuda/kaminari/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amatsuda/kaminari/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amatsuda/kaminari/teams","hooks_url":"https://api.github.com/repos/amatsuda/kaminari/hooks","issue_events_url":"https://api.github.com/repos/amatsuda/kaminari/issues/events{/number}","events_url":"https://api.github.com/repos/amatsuda/kaminari/events","assignees_url":"https://api.github.com/repos/amatsuda/kaminari/assignees{/user}","branches_url":"https://api.github.com/repos/amatsuda/kaminari/branches{/branch}","tags_url":"https://api.github.com/repos/amatsuda/kaminari/tags","blobs_url":"https://api.github.com/repos/amatsuda/kaminari/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amatsuda/kaminari/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amatsuda/kaminari/git/refs{/sha}","trees_url":"https://api.github.com/repos/amatsuda/kaminari/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amatsuda/kaminari/statuses/{sha}","languages_url":"https://api.github.com/repos/amatsuda/kaminari/languages","stargazers_url":"https://api.github.com/repos/amatsuda/kaminari/stargazers","contributors_url":"https://api.github.com/repos/amatsuda/kaminari/contributors","subscribers_url":"https://api.github.com/repos/amatsuda/kaminari/subscribers","subscription_url":"https://api.github.com/repos/amatsuda/kaminari/subscription","commits_url":"https://api.github.com/repos/amatsuda/kaminari/commits{/sha}","git_commits_url":"https://api.github.com/repos/amatsuda/kaminari/git/commits{/sha}","comments_url":"https://api.github.com/repos/amatsuda/kaminari/comments{/number}","issue_comment_url":"https://api.github.com/repos/amatsuda/kaminari/issues/comments{/number}","contents_url":"https://api.github.com/repos/amatsuda/kaminari/contents/{+path}","compare_url":"https://api.github.com/repos/amatsuda/kaminari/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amatsuda/kaminari/merges","archive_url":"https://api.github.com/repos/amatsuda/kaminari/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amatsuda/kaminari/downloads","issues_url":"https://api.github.com/repos/amatsuda/kaminari/issues{/number}","pulls_url":"https://api.github.com/repos/amatsuda/kaminari/pulls{/number}","milestones_url":"https://api.github.com/repos/amatsuda/kaminari/milestones{/number}","notifications_url":"https://api.github.com/repos/amatsuda/kaminari/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amatsuda/kaminari/labels{/name}","releases_url":"https://api.github.com/repos/amatsuda/kaminari/releases{/id}","deployments_url":"https://api.github.com/repos/amatsuda/kaminari/deployments","created_at":"2011-02-06T08:07:20Z","updated_at":"2016-11-15T19:38:18Z","pushed_at":"2016-11-15T06:34:19Z","git_url":"git://github.com/amatsuda/kaminari.git","ssh_url":"git@github.com:amatsuda/kaminari.git","clone_url":"https://github.com/amatsuda/kaminari.git","svn_url":"https://github.com/amatsuda/kaminari","homepage":"https://github.com/amatsuda/kaminari/wiki","size":2114,"stargazers_count":6091,"watchers_count":6091,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":812,"mirror_url":null,"open_issues_count":21,"forks":812,"open_issues":21,"watchers":6091,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amatsuda/kaminari/pulls/573"},"html":{"href":"https://github.com/amatsuda/kaminari/pull/573"},"issue":{"href":"https://api.github.com/repos/amatsuda/kaminari/issues/573"},"comments":{"href":"https://api.github.com/repos/amatsuda/kaminari/issues/573/comments"},"review_comments":{"href":"https://api.github.com/repos/amatsuda/kaminari/pulls/573/comments"},"review_comment":{"href":"https://api.github.com/repos/amatsuda/kaminari/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amatsuda/kaminari/pulls/573/commits"},"statuses":{"href":"https://api.github.com/repos/amatsuda/kaminari/statuses/8a526a226bb361bcf8dbc9e1f3bc972e289bd245"}}}}
{"actor":{"display_login":"yuki24"}}