GitHub PullRequestEvent at 2014-03-10 20:21:43
Repository: elasticsearch-rails
Actor: fcheung
Payload: {"action":"opened","number":36,"pull_request":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/36","id":13391512,"html_url":"https://github.com/elasticsearch/elasticsearch-rails/pull/36","diff_url":"https://github.com/elasticsearch/elasticsearch-rails/pull/36.diff","patch_url":"https://github.com/elasticsearch/elasticsearch-rails/pull/36.patch","issue_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/issues/36","number":36,"state":"open","title":"Elasticsearch::Model::Adapter::ActiveRecord not ensuring order in some cases","user":{"login":"fcheung","id":5927,"avatar_url":"https://gravatar.com/avatar/81b61875e41eaa58887543635d556fca?d=https%3A%2F%2Fidenticons.github.com%2Fc8afe805c097dab1f1e5bdd57f8d2931.png&r=x","gravatar_id":"81b61875e41eaa58887543635d556fca","url":"https://api.github.com/users/fcheung","html_url":"https://github.com/fcheung","followers_url":"https://api.github.com/users/fcheung/followers","following_url":"https://api.github.com/users/fcheung/following{/other_user}","gists_url":"https://api.github.com/users/fcheung/gists{/gist_id}","starred_url":"https://api.github.com/users/fcheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fcheung/subscriptions","organizations_url":"https://api.github.com/users/fcheung/orgs","repos_url":"https://api.github.com/users/fcheung/repos","events_url":"https://api.github.com/users/fcheung/events{/privacy}","received_events_url":"https://api.github.com/users/fcheung/received_events","type":"User","site_admin":false},"body":"The adapter adds an order singleton method that in effect removes the special version of to_a added earlier. \r\nHowever, calling first and last adds an explicit order by primary key, so when calling these methods we always throw away the elastic search generated ordering\r\n\r\nI've attached a failing test for this.\r\n\r\nThe where('1=1') is importing here (anything like joins, includes, etc.) would do: without it the implementation of first that is called is the one from Enumerable, rather than calling first on the relation\r\n\r\nI also noticed that some of the [finder methods](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/finder_methods.rb#L460) operate on `@records` directly if it is loaded - there could be some edge cases here.\r\n\r\nNot sure what the best way forward is. One way would be to make this a true relation by doing something like `.order(\"fields(#{klass.primary_key},1,2,3\")` so that then the relation is just a normal relation. Or perhaps what `records` requires is just a bit too clever and makes too much use of AR internals","created_at":"2014-03-10T20:21:43Z","updated_at":"2014-03-10T20:21:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/36/commits","review_comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/36/comments","review_comment_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/comments/{number}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/issues/36/comments","statuses_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/statuses/13476cf2cb08c11deabb2dbb42926d696b104571","head":{"label":"fcheung:failing_first","ref":"failing_first","sha":"13476cf2cb08c11deabb2dbb42926d696b104571","user":{"login":"fcheung","id":5927,"avatar_url":"https://gravatar.com/avatar/81b61875e41eaa58887543635d556fca?d=https%3A%2F%2Fidenticons.github.com%2Fc8afe805c097dab1f1e5bdd57f8d2931.png&r=x","gravatar_id":"81b61875e41eaa58887543635d556fca","url":"https://api.github.com/users/fcheung","html_url":"https://github.com/fcheung","followers_url":"https://api.github.com/users/fcheung/followers","following_url":"https://api.github.com/users/fcheung/following{/other_user}","gists_url":"https://api.github.com/users/fcheung/gists{/gist_id}","starred_url":"https://api.github.com/users/fcheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fcheung/subscriptions","organizations_url":"https://api.github.com/users/fcheung/orgs","repos_url":"https://api.github.com/users/fcheung/repos","events_url":"https://api.github.com/users/fcheung/events{/privacy}","received_events_url":"https://api.github.com/users/fcheung/received_events","type":"User","site_admin":false},"repo":{"id":17606873,"name":"elasticsearch-rails","full_name":"fcheung/elasticsearch-rails","owner":{"login":"fcheung","id":5927,"avatar_url":"https://gravatar.com/avatar/81b61875e41eaa58887543635d556fca?d=https%3A%2F%2Fidenticons.github.com%2Fc8afe805c097dab1f1e5bdd57f8d2931.png&r=x","gravatar_id":"81b61875e41eaa58887543635d556fca","url":"https://api.github.com/users/fcheung","html_url":"https://github.com/fcheung","followers_url":"https://api.github.com/users/fcheung/followers","following_url":"https://api.github.com/users/fcheung/following{/other_user}","gists_url":"https://api.github.com/users/fcheung/gists{/gist_id}","starred_url":"https://api.github.com/users/fcheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fcheung/subscriptions","organizations_url":"https://api.github.com/users/fcheung/orgs","repos_url":"https://api.github.com/users/fcheung/repos","events_url":"https://api.github.com/users/fcheung/events{/privacy}","received_events_url":"https://api.github.com/users/fcheung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fcheung/elasticsearch-rails","description":"Elasticsearch integrations for ActiveModel/Record and Ruby on Rails","fork":true,"url":"https://api.github.com/repos/fcheung/elasticsearch-rails","forks_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/forks","keys_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/teams","hooks_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/hooks","issue_events_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/issues/events{/number}","events_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/events","assignees_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/assignees{/user}","branches_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/branches{/branch}","tags_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/tags","blobs_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/languages","stargazers_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/stargazers","contributors_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/contributors","subscribers_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/subscribers","subscription_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/subscription","commits_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/contents/{+path}","compare_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/merges","archive_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/downloads","issues_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/issues{/number}","pulls_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/labels{/name}","releases_url":"https://api.github.com/repos/fcheung/elasticsearch-rails/releases{/id}","created_at":"2014-03-10T20:12:28Z","updated_at":"2014-03-10T20:21:43Z","pushed_at":"2014-03-10T20:13:22Z","git_url":"git://github.com/fcheung/elasticsearch-rails.git","ssh_url":"git@github.com:fcheung/elasticsearch-rails.git","clone_url":"https://github.com/fcheung/elasticsearch-rails.git","svn_url":"https://github.com/fcheung/elasticsearch-rails","homepage":"","size":5732,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","master_branch":"master"}},"base":{"label":"elasticsearch:master","ref":"master","sha":"527e2075ae812db9b7043e4fcc9bc493451f3bec","user":{"login":"elasticsearch","id":141304,"avatar_url":"https://gravatar.com/avatar/1aecf795625bbc7251068cfbc39800ab?d=https%3A%2F%2Fidenticons.github.com%2F61ac5f52105a6cfd090389f295c1a7f9.png&r=x","gravatar_id":"1aecf795625bbc7251068cfbc39800ab","url":"https://api.github.com/users/elasticsearch","html_url":"https://github.com/elasticsearch","followers_url":"https://api.github.com/users/elasticsearch/followers","following_url":"https://api.github.com/users/elasticsearch/following{/other_user}","gists_url":"https://api.github.com/users/elasticsearch/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticsearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticsearch/subscriptions","organizations_url":"https://api.github.com/users/elasticsearch/orgs","repos_url":"https://api.github.com/users/elasticsearch/repos","events_url":"https://api.github.com/users/elasticsearch/events{/privacy}","received_events_url":"https://api.github.com/users/elasticsearch/received_events","type":"Organization","site_admin":false},"repo":{"id":14238949,"name":"elasticsearch-rails","full_name":"elasticsearch/elasticsearch-rails","owner":{"login":"elasticsearch","id":141304,"avatar_url":"https://gravatar.com/avatar/1aecf795625bbc7251068cfbc39800ab?d=https%3A%2F%2Fidenticons.github.com%2F61ac5f52105a6cfd090389f295c1a7f9.png&r=x","gravatar_id":"1aecf795625bbc7251068cfbc39800ab","url":"https://api.github.com/users/elasticsearch","html_url":"https://github.com/elasticsearch","followers_url":"https://api.github.com/users/elasticsearch/followers","following_url":"https://api.github.com/users/elasticsearch/following{/other_user}","gists_url":"https://api.github.com/users/elasticsearch/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticsearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticsearch/subscriptions","organizations_url":"https://api.github.com/users/elasticsearch/orgs","repos_url":"https://api.github.com/users/elasticsearch/repos","events_url":"https://api.github.com/users/elasticsearch/events{/privacy}","received_events_url":"https://api.github.com/users/elasticsearch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elasticsearch/elasticsearch-rails","description":"Elasticsearch integrations for ActiveModel/Record and Ruby on Rails","fork":false,"url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails","forks_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/forks","keys_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/teams","hooks_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/hooks","issue_events_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/issues/events{/number}","events_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/events","assignees_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/assignees{/user}","branches_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/branches{/branch}","tags_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/tags","blobs_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/languages","stargazers_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/stargazers","contributors_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/contributors","subscribers_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/subscribers","subscription_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/subscription","commits_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/contents/{+path}","compare_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/merges","archive_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/downloads","issues_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/issues{/number}","pulls_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/labels{/name}","releases_url":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/releases{/id}","created_at":"2013-11-08T17:00:19Z","updated_at":"2014-03-05T18:02:56Z","pushed_at":"2014-03-05T18:02:56Z","git_url":"git://github.com/elasticsearch/elasticsearch-rails.git","ssh_url":"git@github.com:elasticsearch/elasticsearch-rails.git","clone_url":"https://github.com/elasticsearch/elasticsearch-rails.git","svn_url":"https://github.com/elasticsearch/elasticsearch-rails","homepage":"","size":5732,"stargazers_count":260,"watchers_count":260,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":27,"mirror_url":null,"open_issues_count":13,"forks":27,"open_issues":13,"watchers":260,"default_branch":"master","master_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/36"},"html":{"href":"https://github.com/elasticsearch/elasticsearch-rails/pull/36"},"issue":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/issues/36"},"comments":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch-rails/statuses/13476cf2cb08c11deabb2dbb42926d696b104571"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":9,"deletions":0,"changed_files":1}}