{"action":"created","issue":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/4613","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/4613/labels{/name}","comments_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/4613/comments","events_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/4613/events","html_url":"https://github.com/rethinkdb/rethinkdb/issues/4613","id":98566485,"number":4613,"title":"r.literal can be used in update but not in a branch update","user":{"login":"gjuchault","id":678848,"avatar_url":"https://avatars.githubusercontent.com/u/678848?v=3","gravatar_id":"","url":"https://api.github.com/users/gjuchault","html_url":"https://github.com/gjuchault","followers_url":"https://api.github.com/users/gjuchault/followers","following_url":"https://api.github.com/users/gjuchault/following{/other_user}","gists_url":"https://api.github.com/users/gjuchault/gists{/gist_id}","starred_url":"https://api.github.com/users/gjuchault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjuchault/subscriptions","organizations_url":"https://api.github.com/users/gjuchault/orgs","repos_url":"https://api.github.com/users/gjuchault/repos","events_url":"https://api.github.com/users/gjuchault/events{/privacy}","received_events_url":"https://api.github.com/users/gjuchault/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/17","html_url":"https://github.com/rethinkdb/rethinkdb/milestones/duplicate","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/17/labels","id":299323,"number":17,"title":"duplicate","description":"The scope of this issue is covered by another issue. The closing comment should link to the other issue.","creator":{"login":"AtnNn","id":706854,"avatar_url":"https://avatars.githubusercontent.com/u/706854?v=3","gravatar_id":"","url":"https://api.github.com/users/AtnNn","html_url":"https://github.com/AtnNn","followers_url":"https://api.github.com/users/AtnNn/followers","following_url":"https://api.github.com/users/AtnNn/following{/other_user}","gists_url":"https://api.github.com/users/AtnNn/gists{/gist_id}","starred_url":"https://api.github.com/users/AtnNn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AtnNn/subscriptions","organizations_url":"https://api.github.com/users/AtnNn/orgs","repos_url":"https://api.github.com/users/AtnNn/repos","events_url":"https://api.github.com/users/AtnNn/events{/privacy}","received_events_url":"https://api.github.com/users/AtnNn/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":438,"state":"closed","created_at":"2013-03-29T20:23:12Z","updated_at":"2015-08-03T18:29:01Z","due_on":null,"closed_at":"2013-06-11T02:20:11Z"},"comments":2,"created_at":"2015-08-01T22:53:52Z","updated_at":"2015-08-03T18:40:51Z","closed_at":"2015-08-03T18:28:56Z","body":"Hi,\r\n\r\nThis sample works :\r\n```js\r\nr.db('db').table('test').get('id').update(function (item) {\r\n    return { foo : r.literal({}) };\r\n});\r\n```\r\n\r\nNot that one :\r\n```js\r\nr.db('db').table('test').get('id').update(function (item) {\r\n  return r.branch(\r\n    true,\r\n    { foo: r.literal({}) },\r\n    { foo: r.literal({}) }\r\n});\r\n```\r\n\r\nError : `Stray literal keyword found: literal is only legal inside of the object passed to merge or update and cannot nest inside other literals.`\r\nI think as literal parent node is branch; the error is thrown.\r\nCan be done with nested branch too :\r\n```js\r\nr.db('db').table('test').get('id').update(function (item) {\r\n  return r.branch(\r\n    true,\r\n    r.branch(\r\n        true,\r\n        { foo: r.literal({}) },\r\n        { foo: r.literal({}) }\r\n    ),\r\n    { foo: r.literal({}) }\r\n});\r\n```\r\n\r\nWhich mean a recursive parent node check should be done to ensure the update function is called; before throwing because of a branch."},"comment":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/comments/127365722","html_url":"https://github.com/rethinkdb/rethinkdb/issues/4613#issuecomment-127365722","issue_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/4613","id":127365722,"user":{"login":"danielmewes","id":505365,"avatar_url":"https://avatars.githubusercontent.com/u/505365?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmewes","html_url":"https://github.com/danielmewes","followers_url":"https://api.github.com/users/danielmewes/followers","following_url":"https://api.github.com/users/danielmewes/following{/other_user}","gists_url":"https://api.github.com/users/danielmewes/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmewes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmewes/subscriptions","organizations_url":"https://api.github.com/users/danielmewes/orgs","repos_url":"https://api.github.com/users/danielmewes/repos","events_url":"https://api.github.com/users/danielmewes/events{/privacy}","received_events_url":"https://api.github.com/users/danielmewes/received_events","type":"User","site_admin":false},"created_at":"2015-08-03T18:40:51Z","updated_at":"2015-08-03T18:40:51Z","body":"Also see https://github.com/rethinkdb/rethinkdb/issues/4604#issuecomment-127362173 for a work-around for your case."}}