{"action":"closed","number":19375,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/19375","id":31328261,"html_url":"https://github.com/rails/rails/pull/19375","diff_url":"https://github.com/rails/rails/pull/19375.diff","patch_url":"https://github.com/rails/rails/pull/19375.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/19375","number":19375,"state":"closed","locked":false,"title":"Replace `NullRelation` with a `#null?` state for `Relation`","user":{"login":"Empact","id":5470,"avatar_url":"https://avatars.githubusercontent.com/u/5470?v=3","gravatar_id":"","url":"https://api.github.com/users/Empact","html_url":"https://github.com/Empact","followers_url":"https://api.github.com/users/Empact/followers","following_url":"https://api.github.com/users/Empact/following{/other_user}","gists_url":"https://api.github.com/users/Empact/gists{/gist_id}","starred_url":"https://api.github.com/users/Empact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Empact/subscriptions","organizations_url":"https://api.github.com/users/Empact/orgs","repos_url":"https://api.github.com/users/Empact/repos","events_url":"https://api.github.com/users/Empact/events{/privacy}","received_events_url":"https://api.github.com/users/Empact/received_events","type":"User","site_admin":false},"body":"In all cases where `ActiveRecord` currently generates a query with\r\n `WHERE 1=0`, this will instead avoid the query and return a `#null?` `Relation`,\r\nala `.none`. This covers cases such as `.where('1=0')`, `.where(id: [])`,\r\nand `.limit(0)`.\r\n\r\nThis line of thought was inspired by the need for #19349, which is\r\ncaused `NullRelation` state leaking across `#reset` boundaries. This\r\nalternative is tidier in that it is 100% resetable, and does not\r\nrequire hacky cache clearing.\r\n\r\nNote this patch still needs documentation, and perhaps other refinement,\r\nbut the functionality works as is. This patch would be improved if\r\n`Arel::Nodes::In` responded to a method to indicate when it was a none\r\npredicate - see `WhereClause#none_predicate?`, but I figured I'd get you\r\nguys' opinion on it first.\r\n","created_at":"2015-03-17T11:57:04Z","updated_at":"2015-03-17T21:56:11Z","closed_at":"2015-03-17T21:56:11Z","merged_at":null,"merge_commit_sha":"68d0e827d3d4e7fe70a424f25c1773718fc48d60","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/19375/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/19375/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/19375/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/04398c3015ff39095c553f8cfe756c48d6630f5c","head":{"label":"Empact:none-relation","ref":"none-relation","sha":"04398c3015ff39095c553f8cfe756c48d6630f5c","user":{"login":"Empact","id":5470,"avatar_url":"https://avatars.githubusercontent.com/u/5470?v=3","gravatar_id":"","url":"https://api.github.com/users/Empact","html_url":"https://github.com/Empact","followers_url":"https://api.github.com/users/Empact/followers","following_url":"https://api.github.com/users/Empact/following{/other_user}","gists_url":"https://api.github.com/users/Empact/gists{/gist_id}","starred_url":"https://api.github.com/users/Empact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Empact/subscriptions","organizations_url":"https://api.github.com/users/Empact/orgs","repos_url":"https://api.github.com/users/Empact/repos","events_url":"https://api.github.com/users/Empact/events{/privacy}","received_events_url":"https://api.github.com/users/Empact/received_events","type":"User","site_admin":false},"repo":{"id":1558716,"name":"rails","full_name":"Empact/rails","owner":{"login":"Empact","id":5470,"avatar_url":"https://avatars.githubusercontent.com/u/5470?v=3","gravatar_id":"","url":"https://api.github.com/users/Empact","html_url":"https://github.com/Empact","followers_url":"https://api.github.com/users/Empact/followers","following_url":"https://api.github.com/users/Empact/following{/other_user}","gists_url":"https://api.github.com/users/Empact/gists{/gist_id}","starred_url":"https://api.github.com/users/Empact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Empact/subscriptions","organizations_url":"https://api.github.com/users/Empact/orgs","repos_url":"https://api.github.com/users/Empact/repos","events_url":"https://api.github.com/users/Empact/events{/privacy}","received_events_url":"https://api.github.com/users/Empact/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Empact/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/Empact/rails","forks_url":"https://api.github.com/repos/Empact/rails/forks","keys_url":"https://api.github.com/repos/Empact/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Empact/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Empact/rails/teams","hooks_url":"https://api.github.com/repos/Empact/rails/hooks","issue_events_url":"https://api.github.com/repos/Empact/rails/issues/events{/number}","events_url":"https://api.github.com/repos/Empact/rails/events","assignees_url":"https://api.github.com/repos/Empact/rails/assignees{/user}","branches_url":"https://api.github.com/repos/Empact/rails/branches{/branch}","tags_url":"https://api.github.com/repos/Empact/rails/tags","blobs_url":"https://api.github.com/repos/Empact/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Empact/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Empact/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/Empact/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Empact/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/Empact/rails/languages","stargazers_url":"https://api.github.com/repos/Empact/rails/stargazers","contributors_url":"https://api.github.com/repos/Empact/rails/contributors","subscribers_url":"https://api.github.com/repos/Empact/rails/subscribers","subscription_url":"https://api.github.com/repos/Empact/rails/subscription","commits_url":"https://api.github.com/repos/Empact/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/Empact/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/Empact/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/Empact/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/Empact/rails/contents/{+path}","compare_url":"https://api.github.com/repos/Empact/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Empact/rails/merges","archive_url":"https://api.github.com/repos/Empact/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Empact/rails/downloads","issues_url":"https://api.github.com/repos/Empact/rails/issues{/number}","pulls_url":"https://api.github.com/repos/Empact/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/Empact/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/Empact/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Empact/rails/labels{/name}","releases_url":"https://api.github.com/repos/Empact/rails/releases{/id}","created_at":"2011-04-02T06:19:39Z","updated_at":"2015-03-10T00:47:32Z","pushed_at":"2015-03-17T17:43:17Z","git_url":"git://github.com/Empact/rails.git","ssh_url":"git@github.com:Empact/rails.git","clone_url":"https://github.com/Empact/rails.git","svn_url":"https://github.com/Empact/rails","homepage":"http://rubyonrails.org","size":119070,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"80f66d405ce0e7c9be1ddf599104b9bcfe6c0e88","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-03-17T20:48:50Z","pushed_at":"2015-03-17T20:31:55Z","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":390514,"stargazers_count":25293,"watchers_count":25293,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9912,"mirror_url":null,"open_issues_count":724,"forks":9912,"open_issues":724,"watchers":25293,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/19375"},"html":{"href":"https://github.com/rails/rails/pull/19375"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/19375"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/19375/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/19375/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/19375/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/04398c3015ff39095c553f8cfe756c48d6630f5c"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":7,"review_comments":1,"commits":3,"additions":1556,"deletions":1429,"changed_files":20}}