{"action":"created","issue":{"url":"https://api.github.com/repos/neumino/rethinkdbdash/issues/115","labels_url":"https://api.github.com/repos/neumino/rethinkdbdash/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/neumino/rethinkdbdash/issues/115/comments","events_url":"https://api.github.com/repos/neumino/rethinkdbdash/issues/115/events","html_url":"https://github.com/neumino/rethinkdbdash/issues/115","id":96636701,"number":115,"title":"Exception for r.and when used with r.args","user":{"login":"alexeygolev","id":1342730,"avatar_url":"https://avatars.githubusercontent.com/u/1342730?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeygolev","html_url":"https://github.com/alexeygolev","followers_url":"https://api.github.com/users/alexeygolev/followers","following_url":"https://api.github.com/users/alexeygolev/following{/other_user}","gists_url":"https://api.github.com/users/alexeygolev/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeygolev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeygolev/subscriptions","organizations_url":"https://api.github.com/users/alexeygolev/orgs","repos_url":"https://api.github.com/users/alexeygolev/repos","events_url":"https://api.github.com/users/alexeygolev/events{/privacy}","received_events_url":"https://api.github.com/users/alexeygolev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-22T18:43:13Z","updated_at":"2015-07-23T15:02:04Z","closed_at":null,"body":"The following code works in _Data Explorer_\r\n```javascript\r\nr.db('db').table('table')\r\n    .coerceTo('array')\r\n    .filter(function(cP){\r\n      return r.and(r.args(r.expr([{\r\n          ids:['1bc07fca-2f68-4e2e-bc47-022b162f81a9', 'd4b99c17-eea8-4583-b34e-2a9dd6174f90'],\r\n          all: true\r\n        },\r\n        {\r\n          ids:['bc2232ee-ce92-4c4d-999e-c52719dd79ea'],\r\n          all: false\r\n        }]).map(\r\n        function(rule) {\r\n          return r.branch (\r\n            rule('all'),\r\n            r.and(r.args(rule('ids').map(function(id){\r\n              return cP('tags').contains(id)\r\n            }))),\r\n            r.and(r.args(rule('ids').map(function(id){\r\n              return cP('tags').contains(id)\r\n            }))))\r\n        }\r\n      )))\r\n })\r\n\r\n```\r\n\r\nBut throws this when used with rethinkdbdash\r\n``` \r\nReqlDriverError: `and` takes at least 1 argument, 0 provided after:\r\n  r.args(var_2(\"ids\").map(function(var_3) {\r\n      return var_1(\"tags\").contains(var_3)\r\n  }))\r\n```\r\n`r.or` throws as well.\r\nAs far as I can understand from reading rethinkdbdash's source and tests, it throws the error for the _infix_ version of `and` (otherwise it would have thrown 'at least 2' according to the tests). Not sure why. In any case it doesn't seem to like `r.args` that much.\r\n\r\nThis is an ES6 version which is a bit easier to read\r\n```javascript\r\n  return r.db('db').table('table')\r\n    .coerceTo('array')\r\n    .filter(cP => r.and(r.args(r.expr(rules)\r\n      .map(rule => r.branch(\r\n        rule('all'),\r\n        r.and(r.args(rule('ids').map(id => cP('tags').contains(id)))),\r\n        r.or(r.args(rule('ids').map(id => cP('tags').contains(id))))\r\n      )))))\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/neumino/rethinkdbdash/issues/comments/124133234","html_url":"https://github.com/neumino/rethinkdbdash/issues/115#issuecomment-124133234","issue_url":"https://api.github.com/repos/neumino/rethinkdbdash/issues/115","id":124133234,"user":{"login":"alexeygolev","id":1342730,"avatar_url":"https://avatars.githubusercontent.com/u/1342730?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeygolev","html_url":"https://github.com/alexeygolev","followers_url":"https://api.github.com/users/alexeygolev/followers","following_url":"https://api.github.com/users/alexeygolev/following{/other_user}","gists_url":"https://api.github.com/users/alexeygolev/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeygolev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeygolev/subscriptions","organizations_url":"https://api.github.com/users/alexeygolev/orgs","repos_url":"https://api.github.com/users/alexeygolev/repos","events_url":"https://api.github.com/users/alexeygolev/events{/privacy}","received_events_url":"https://api.github.com/users/alexeygolev/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T15:02:04Z","updated_at":"2015-07-23T15:02:04Z","body":"From what I can see in the source `r.and` calls its \"infix\" version internally.\r\nhttps://github.com/neumino/rethinkdbdash/blob/master/lib/index.js#L244\r\nThe problem though that we are effectively ending up with `r.expr(r.args(...)).and(undefined)`.\r\nThis way when `Term.prototype.and` does the `_arityRange` here\r\nhttps://github.com/neumino/rethinkdbdash/blob/master/lib/term.js#L1609\r\nit throws an error.\r\n"}}