{"action":"created","issue":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/1721","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/1721/labels{/name}","comments_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/1721/comments","events_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/1721/events","html_url":"https://github.com/rethinkdb/rethinkdb/issues/1721","id":23422711,"number":1721,"title":"Make `filter` less bad","user":{"login":"mlucy","id":1777134,"avatar_url":"https://avatars.githubusercontent.com/u/1777134?v=3","gravatar_id":"","url":"https://api.github.com/users/mlucy","html_url":"https://github.com/mlucy","followers_url":"https://api.github.com/users/mlucy/followers","following_url":"https://api.github.com/users/mlucy/following{/other_user}","gists_url":"https://api.github.com/users/mlucy/gists{/gist_id}","starred_url":"https://api.github.com/users/mlucy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlucy/subscriptions","organizations_url":"https://api.github.com/users/mlucy/orgs","repos_url":"https://api.github.com/users/mlucy/repos","events_url":"https://api.github.com/users/mlucy/events{/privacy}","received_events_url":"https://api.github.com/users/mlucy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/labels/tp%3ARQL_proposal","name":"tp:RQL_proposal","color":"0052cc"}],"state":"open","locked":false,"assignee":{"login":"mlucy","id":1777134,"avatar_url":"https://avatars.githubusercontent.com/u/1777134?v=3","gravatar_id":"","url":"https://api.github.com/users/mlucy","html_url":"https://github.com/mlucy","followers_url":"https://api.github.com/users/mlucy/followers","following_url":"https://api.github.com/users/mlucy/following{/other_user}","gists_url":"https://api.github.com/users/mlucy/gists{/gist_id}","starred_url":"https://api.github.com/users/mlucy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlucy/subscriptions","organizations_url":"https://api.github.com/users/mlucy/orgs","repos_url":"https://api.github.com/users/mlucy/repos","events_url":"https://api.github.com/users/mlucy/events{/privacy}","received_events_url":"https://api.github.com/users/mlucy/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/41","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/41/labels","id":367201,"number":41,"title":"subsequent","description":"","creator":{"login":"coffeemug","id":48436,"avatar_url":"https://avatars.githubusercontent.com/u/48436?v=3","gravatar_id":"","url":"https://api.github.com/users/coffeemug","html_url":"https://github.com/coffeemug","followers_url":"https://api.github.com/users/coffeemug/followers","following_url":"https://api.github.com/users/coffeemug/following{/other_user}","gists_url":"https://api.github.com/users/coffeemug/gists{/gist_id}","starred_url":"https://api.github.com/users/coffeemug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coffeemug/subscriptions","organizations_url":"https://api.github.com/users/coffeemug/orgs","repos_url":"https://api.github.com/users/coffeemug/repos","events_url":"https://api.github.com/users/coffeemug/events{/privacy}","received_events_url":"https://api.github.com/users/coffeemug/received_events","type":"User","site_admin":false},"open_issues":304,"closed_issues":1,"state":"open","created_at":"2013-06-30T07:32:52Z","updated_at":"2015-01-13T21:43:35Z","due_on":null,"closed_at":null},"comments":32,"created_at":"2013-11-27T23:50:23Z","updated_at":"2015-01-13T22:14:29Z","closed_at":null,"body":"We've been talking about the problems with the implicit default in `filter` for a while now (see e.g. https://github.com/rethinkdb/rethinkdb/issues/1580).  I think it would be really great to improve this.\r\n\r\nThree ideas, from least to most radical:\r\n\r\n#### 1. Patch it: make filter variadic to solve the `r.any` problem, ignore everything else.\r\n\r\nWe can make filter variadic, so that people can write `table.filter({a:1}, {b:2})` to mean `table.filter{|row| row[:a].eq(1).default(false).or(row[:b].eq(2).default(false))}`.\r\n\r\n#### 2. Get rid of the implicit default on filter.\r\n\r\nWe originally added it because it is incredibly annoying to write a simple `filter` query and have it not work because some documents are missing a field.  @coffeemug, I realize that you don't want to re-visit this, but I think the problems have turned out to be larger than we thought.\r\n\r\nAnother point in favor of this: part of why it was so annoying is that there was no easy way to fix it.  Now that we have `default`, people can get the current behavior by writing:\r\n```ruby\r\nr.table('test').filter(default:true) {|row| ...}\r\n```\r\n\r\nwhich, while irritating, is much better than their previous option.\r\n\r\nBasically, I think the cost of the implicit default is higher than we thought, and the suckiness of not having it is lower than it used to be, so this decision could really use a second look.\r\n\r\n#### 3. Adopt falsey error semantics.\r\n\r\nBasically, we would switch to treating errors like values instead of exceptions, and we would consider them to be falsey.  So if you wrote `r.any(r.error(\"a\"), 1)`, you would get back `1`.\r\n\r\nThis might seem weird at first, but it actually works pretty well.  This fixes the problem with `r.any` and `r.not` in filter, removes the need for an implicit default, and actually makes a lot of sense in a parallel context.\r\n\r\n---\r\n\r\nWhat do other people think?  Tentatively scheduling this for 1.12, but @coffeemug feel free to prioritize."},"comment":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/comments/69831278","html_url":"https://github.com/rethinkdb/rethinkdb/issues/1721#issuecomment-69831278","issue_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/1721","id":69831278,"user":{"login":"mlucy","id":1777134,"avatar_url":"https://avatars.githubusercontent.com/u/1777134?v=3","gravatar_id":"","url":"https://api.github.com/users/mlucy","html_url":"https://github.com/mlucy","followers_url":"https://api.github.com/users/mlucy/followers","following_url":"https://api.github.com/users/mlucy/following{/other_user}","gists_url":"https://api.github.com/users/mlucy/gists{/gist_id}","starred_url":"https://api.github.com/users/mlucy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlucy/subscriptions","organizations_url":"https://api.github.com/users/mlucy/orgs","repos_url":"https://api.github.com/users/mlucy/repos","events_url":"https://api.github.com/users/mlucy/events{/privacy}","received_events_url":"https://api.github.com/users/mlucy/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T22:14:29Z","updated_at":"2015-01-13T22:14:29Z","body":"@danielmewes: the behavior I suggested mimics how JS treats undefined (as far as I can tell it even mimics it on the edge cases):\r\n```\r\n> 1 || false\r\n1\r\n> 1 || undefined\r\n1\r\n> false || undefined\r\nundefined\r\n> undefined || false\r\nfalse\r\n> false || 1\r\n1\r\n> undefined || 1\r\n1\r\n```\r\n\r\n(In our case, though, we'd rethrow the non-existence error rather than returning undefined.)\r\n\r\nNote that JS also has the following behavior:\r\n```\r\n> !undefined\r\ntrue\r\n```"}}